Skip to content
Snippets Groups Projects
Commit ac982abd authored by Tobias S. Josefowitz's avatar Tobias S. Josefowitz
Browse files

Concurrent: Catch executor throwing and convert to rejection

There is arguably little reason to use the executor 'API' if not for it
doing this.
parent 2af2072a
No related branches found
No related tags found
No related merge requests found
......@@ -906,8 +906,20 @@ class Promise
function(mixed:void), mixed ...:void) executor, mixed ... extra)
{
state = STATE_NO_FUTURE;
if (executor)
executor(success, failure, @extra);
if (executor) {
mixed err = catch(executor(success, failure, @extra));
// This unfortunately does hide the real error in case of
// double-finalization, i.e.
// fail("I reject!");
// error("I rejected.\n");
// in the executor will leave our caller with an error about the
// Promise already having been finalized, not giving anyone too much
// information about where the double-finalization occured...
if (err)
failure(err);
}
}
Future on_success(function(mixed, mixed ... : void) cb, mixed ... extra)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment