Changeset

11210:75636bf13bf0 0.11

util.promise: Use xpcall() for promise function to preserve tracebacks
author Matthew Wild <mwild1@gmail.com>
date Mon, 23 Nov 2020 20:38:51 +0000
parents 11205:9d1e21c23784
children 11211:1151140fc757 11212:1bfd238e05ad
files util/promise.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/promise.lua	Wed Nov 11 16:00:41 2020 +0100
+++ b/util/promise.lua	Mon Nov 23 20:38:51 2020 +0000
@@ -78,7 +78,7 @@
 	local p = setmetatable({ _state = "pending", _next = next_pending, _pending_on_fulfilled = {}, _pending_on_rejected = {} }, promise_mt);
 	if f then
 		local resolve, reject = new_resolve_functions(p);
-		local ok, ret = pcall(f, resolve, reject);
+		local ok, ret = xpcall(f, debug.traceback, resolve, reject);
 		if not ok and p._state == "pending" then
 			reject(ret);
 		end