From d54b902441e6ac6919c0f882b7172b1d36de5a99 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 24 May 2014 15:51:41 +0100 Subject: [PATCH] Modified future behaviour when completing with an exception. Futures will now raise the exception if they did not have a callback associated with them. --- lib/pure/asyncdispatch.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index d972592a5c..9f1711f088 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -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.