Skip to content

Commit

Permalink
Revert "asyncCheck(): don't raise exception on cancellation (#121)"
Browse files Browse the repository at this point in the history
This reverts commit baf33f0.

This change hides exceptions that should be handled explicitly -
asyncCheck is a debugging tool that should only be used in
exception-free situations (indeed, to fail when the operation
unexpectedly raises). There is no rough consensus behind this
change.
  • Loading branch information
zah committed Aug 15, 2020
1 parent baf33f0 commit 34b8196
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chronos/asyncfutures2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,13 @@ proc mget*[T](future: FutureVar[T]): var T =
result = Future[T](future).value

proc asyncCheck*[T](future: Future[T]) =
## Sets a callback on ``future`` which raises an exception in ``poll()`` if the
## future failed.
## Sets a callback on ``future`` which raises an exception if the future
## finished with an error.
##
## This should be used instead of ``discard`` to discard void futures.
doAssert(not isNil(future), "Future is nil")
proc cb(data: pointer) =
if future.failed():
if future.failed() or future.cancelled():
when defined(chronosStackTrace):
injectStacktrace(future)
raise future.error
Expand Down

0 comments on commit 34b8196

Please sign in to comment.