mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-18 06:51:18 +00:00
Modified future behaviour when completing with an exception.
Futures will now raise the exception if they did not have a callback associated with them.
This commit is contained in:
@@ -71,6 +71,11 @@ proc fail*[T](future: PFuture[T], error: ref EBase) =
|
||||
future.error = error
|
||||
if future.cb != nil:
|
||||
future.cb()
|
||||
else:
|
||||
# This is to prevent exceptions from being silently ignored when a future
|
||||
# is discarded.
|
||||
# TODO: This may turn out to be a bad idea.
|
||||
raise error
|
||||
|
||||
proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
|
||||
## Sets the callback proc to be called when the future completes.
|
||||
|
||||
Reference in New Issue
Block a user