diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2017-02-09 23:07:10 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2017-02-09 23:07:10 +0100 |
commit | 32864809856352ad9b537fdb7bc8e936cfdc99ee (patch) | |
tree | b442985d326cb999f4aa147721271f9bc75e04f6 | |
parent | e189004a03fc10a5330caf853f7a287636f679fd (diff) | |
download | Nim-32864809856352ad9b537fdb7bc8e936cfdc99ee.tar.gz |
Improve error message when a `nil` future is await'ed.
-rw-r--r-- | lib/pure/asyncmacro.nim | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index f74881c6d..ba9993b2c 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -33,8 +33,10 @@ template createCb(retFutureSym, iteratorNameSym, if not nameIterVar.finished: var next = nameIterVar() if next == nil: - assert retFutureSym.finished, "Async procedure's (" & - name & ") return Future was not finished." + if not retFutureSym.finished: + let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " & + "`nil` Future?" + raise newException(AssertionError, msg % name) else: next.callback = cb except: @@ -390,7 +392,7 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} = if procBody.kind != nnkEmpty: result[6] = outerProcBody #echo(treeRepr(result)) - #if prc[0].getName == "testInfix": + #if prc[0].getName == "beta": # echo(toStrLit(result)) macro async*(prc: untyped): untyped = |