From fb34809681ecad491fc352325f775254deee21eb Mon Sep 17 00:00:00 2001 From: "Tobias S. Josefowitz" <tobij@tobij.de> Date: Sun, 25 Oct 2020 21:53:58 +0100 Subject: [PATCH] Concurrent: Explicit error on executor rejection failure This is not perfect (as we currently have no way of properly chaining errors), but this should provide more helpful error messages to developers who somehow manage to throw in the executor after finalising the promise some other way. --- lib/modules/Concurrent.pmod | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/modules/Concurrent.pmod b/lib/modules/Concurrent.pmod index 1600837628..a0b383b458 100644 --- a/lib/modules/Concurrent.pmod +++ b/lib/modules/Concurrent.pmod @@ -917,8 +917,20 @@ class Promise // 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); + if (err) { + if (mixed err2 = catch(failure(err))) { + string finalisation_error; + + if (catch(finalisation_error = describe_error(err2))) + finalisation_error = sprintf("%O", err2); + + while (has_suffix(finalisation_error, "\n")) + finalisation_error = finalisation_error[..<1]; + + error("%O->create(): Got error \"%s\" while trying to finalise promise with %O thrown by executor.\n", + this, finalisation_error, err); + } + } } } -- GitLab