diff options
author | Brendan Long <self@brendanlong.com> | 2017-11-04 12:06:25 -0400 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-10-05 17:30:05 +0200 |
commit | 36e8e07cbe530b0296a8af71050e8d35c4251f48 (patch) | |
tree | 96520e5e6de624f809b99d826b0a5ec655faafe3 | |
parent | 505698ad479085ed969b355c243fe457d07fea4c (diff) | |
download | libgee-wip/issue/23.tar.gz |
Keep the original exception in Future.map/flat_mapwip/issue/23
If a chain of maps fails, the final `exception` should be the actual
exception, not a semi-useless `FutureError.EXCEPTION`.
Fixes https://gitlab.gnome.org/GNOME/libgee/issues/23
-rw-r--r-- | gee/future.vala | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gee/future.vala b/gee/future.vala index 654041b..9a004b2 100644 --- a/gee/future.vala +++ b/gee/future.vala @@ -134,6 +134,8 @@ public interface Gee.Future<G> : Object { wait_async.begin ((obj, res) => { try { promise.set_value (func (wait_async.end (res))); + } catch (FutureError.EXCEPTION e) { + promise.set_exception (this.exception); } catch (Error ex) { promise.set_exception ((owned)ex); } @@ -234,8 +236,15 @@ public interface Gee.Future<G> : Object { private static async void do_flat_map<A, B> (owned FlatMapFunc<B, A> func, Future<A> future, Promise<B> promise) { try { A input = yield future.wait_async (); - B output = yield func (input).wait_async (); - promise.set_value ((owned)output); + Future<B> output_future = func (input); + try { + B output = yield output_future.wait_async (); + promise.set_value ((owned)output); + } catch (FutureError.EXCEPTION e) { + promise.set_exception (output_future.exception); + } + } catch (FutureError.EXCEPTION e) { + promise.set_exception (future.exception); } catch (Error ex) { promise.set_exception ((owned)ex); } |