Revert back some exception changes.

This commit is contained in:
cheatfate 2019-12-02 12:40:41 +02:00
parent cb44a30430
commit a20c34603e
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
2 changed files with 8 additions and 6 deletions

View File

@ -53,9 +53,11 @@ type
FutureVar*[T] = distinct Future[T]
FutureError* = object of CatchableError
FutureDefect* = object of Exception
cause*: FutureBase
FutureError* = object of CatchableError
CancelledError* = object of FutureError
var currentID* {.threadvar.}: int
@ -141,7 +143,7 @@ proc failed*(future: FutureBase): bool {.inline.} =
proc checkFinished[T](future: Future[T], loc: ptr SrcLoc) =
## Checks whether `future` is finished. If it is then raises a
## ``FutureError``.
## ``FutureDefect``.
if future.finished():
var msg = ""
msg.add("An attempt was made to complete a Future more than once. ")
@ -161,7 +163,7 @@ proc checkFinished[T](future: Future[T], loc: ptr SrcLoc) =
msg.add("\n Stack trace to moment of secondary completion:")
msg.add("\n" & indent(getStackTrace().strip(), 4))
msg.add("\n\n")
var err = newException(FutureError, msg)
var err = newException(FutureDefect, msg)
err.cause = future
raise err
else:

View File

@ -42,8 +42,8 @@ template createCb(retFutureSym, iteratorNameSym,
if next == nil:
if not(retFutureSym.finished()):
let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " &
"`nil` Future?"
let msg = "Async procedure ($1) yielded `nil`, " &
"are you await'ing a `nil` Future?"
raise newException(AssertionError, msg % strName)
else:
{.gcsafe.}:
@ -52,7 +52,7 @@ template createCb(retFutureSym, iteratorNameSym,
{.pop.}
except CancelledError:
retFutureSym.cancel()
except CatchableError as exc:
except Exception as exc:
futureVarCompletions
if retFutureSym.finished():