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:
parent
b386d38208
commit
d54b902441
1 changed files with 5 additions and 0 deletions
|
|
@ -71,6 +71,11 @@ proc fail*[T](future: PFuture[T], error: ref EBase) =
|
||||||
future.error = error
|
future.error = error
|
||||||
if future.cb != nil:
|
if future.cb != nil:
|
||||||
future.cb()
|
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.}) =
|
proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
|
||||||
## Sets the callback proc to be called when the future completes.
|
## Sets the callback proc to be called when the future completes.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue