Revert "asyncCheck(): don't raise exception on cancellation (#121)"

This reverts commit baf33f04eaac481251ca306258ca5877e7a45a46.

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.
This commit is contained in:
Zahary Karadjov 2020-08-16 01:34:42 +03:00 committed by zah
parent baf33f04ea
commit 34b81961d3

View File

@ -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