mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-01-18 23:31:13 +00:00
asyncCheck(): don't raise exception on cancellation (#121)
This commit is contained in:
parent
284d677815
commit
baf33f04ea
@ -531,13 +531,11 @@ 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 if the future
|
||||
## finished with an error.
|
||||
##
|
||||
## This should be used instead of ``discard`` to discard void futures.
|
||||
## Sets a callback on ``future`` which raises an exception in ``poll()`` if the
|
||||
## future failed.
|
||||
doAssert(not isNil(future), "Future is nil")
|
||||
proc cb(data: pointer) =
|
||||
if future.failed() or future.cancelled():
|
||||
if future.failed():
|
||||
when defined(chronosStackTrace):
|
||||
injectStacktrace(future)
|
||||
raise future.error
|
||||
|
Loading…
x
Reference in New Issue
Block a user