mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-20 23:18:22 +00:00
Revert back some exception changes.
This commit is contained in:
parent
cb44a30430
commit
a20c34603e
@ -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:
|
||||
|
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user