Improve error message when a nil future is await'ed.
This commit is contained in:
parent
e189004a03
commit
3286480985
1 changed files with 5 additions and 3 deletions
|
|
@ -33,8 +33,10 @@ template createCb(retFutureSym, iteratorNameSym,
|
||||||
if not nameIterVar.finished:
|
if not nameIterVar.finished:
|
||||||
var next = nameIterVar()
|
var next = nameIterVar()
|
||||||
if next == nil:
|
if next == nil:
|
||||||
assert retFutureSym.finished, "Async procedure's (" &
|
if not retFutureSym.finished:
|
||||||
name & ") return Future was not finished."
|
let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " &
|
||||||
|
"`nil` Future?"
|
||||||
|
raise newException(AssertionError, msg % name)
|
||||||
else:
|
else:
|
||||||
next.callback = cb
|
next.callback = cb
|
||||||
except:
|
except:
|
||||||
|
|
@ -390,7 +392,7 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
|
||||||
if procBody.kind != nnkEmpty:
|
if procBody.kind != nnkEmpty:
|
||||||
result[6] = outerProcBody
|
result[6] = outerProcBody
|
||||||
#echo(treeRepr(result))
|
#echo(treeRepr(result))
|
||||||
#if prc[0].getName == "testInfix":
|
#if prc[0].getName == "beta":
|
||||||
# echo(toStrLit(result))
|
# echo(toStrLit(result))
|
||||||
|
|
||||||
macro async*(prc: untyped): untyped =
|
macro async*(prc: untyped): untyped =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue