mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-22 07:58:12 +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]
|
FutureVar*[T] = distinct Future[T]
|
||||||
|
|
||||||
FutureError* = object of CatchableError
|
FutureDefect* = object of Exception
|
||||||
cause*: FutureBase
|
cause*: FutureBase
|
||||||
|
|
||||||
|
FutureError* = object of CatchableError
|
||||||
|
|
||||||
CancelledError* = object of FutureError
|
CancelledError* = object of FutureError
|
||||||
|
|
||||||
var currentID* {.threadvar.}: int
|
var currentID* {.threadvar.}: int
|
||||||
@ -141,7 +143,7 @@ proc failed*(future: FutureBase): bool {.inline.} =
|
|||||||
|
|
||||||
proc checkFinished[T](future: Future[T], loc: ptr SrcLoc) =
|
proc checkFinished[T](future: Future[T], loc: ptr SrcLoc) =
|
||||||
## Checks whether `future` is finished. If it is then raises a
|
## Checks whether `future` is finished. If it is then raises a
|
||||||
## ``FutureError``.
|
## ``FutureDefect``.
|
||||||
if future.finished():
|
if future.finished():
|
||||||
var msg = ""
|
var msg = ""
|
||||||
msg.add("An attempt was made to complete a Future more than once. ")
|
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 Stack trace to moment of secondary completion:")
|
||||||
msg.add("\n" & indent(getStackTrace().strip(), 4))
|
msg.add("\n" & indent(getStackTrace().strip(), 4))
|
||||||
msg.add("\n\n")
|
msg.add("\n\n")
|
||||||
var err = newException(FutureError, msg)
|
var err = newException(FutureDefect, msg)
|
||||||
err.cause = future
|
err.cause = future
|
||||||
raise err
|
raise err
|
||||||
else:
|
else:
|
||||||
|
@ -42,8 +42,8 @@ template createCb(retFutureSym, iteratorNameSym,
|
|||||||
|
|
||||||
if next == nil:
|
if next == nil:
|
||||||
if not(retFutureSym.finished()):
|
if not(retFutureSym.finished()):
|
||||||
let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " &
|
let msg = "Async procedure ($1) yielded `nil`, " &
|
||||||
"`nil` Future?"
|
"are you await'ing a `nil` Future?"
|
||||||
raise newException(AssertionError, msg % strName)
|
raise newException(AssertionError, msg % strName)
|
||||||
else:
|
else:
|
||||||
{.gcsafe.}:
|
{.gcsafe.}:
|
||||||
@ -52,7 +52,7 @@ template createCb(retFutureSym, iteratorNameSym,
|
|||||||
{.pop.}
|
{.pop.}
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
retFutureSym.cancel()
|
retFutureSym.cancel()
|
||||||
except CatchableError as exc:
|
except Exception as exc:
|
||||||
futureVarCompletions
|
futureVarCompletions
|
||||||
|
|
||||||
if retFutureSym.finished():
|
if retFutureSym.finished():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user