util.async: Convert asserts to a return false (same as other unexpected behaviour)
authorMatthew Wild <mwild1@gmail.com>
Sat, 17 Mar 2018 11:46:21 +0000
changeset 8616 dbb4788db8e3
parent 8615 1f2fb8070c7c
child 8617 bfbafeced0c4
util.async: Convert asserts to a return false (same as other unexpected behaviour)
util/async.lua
--- a/util/async.lua	Sat Mar 17 09:31:57 2018 +0000
+++ b/util/async.lua	Sat Mar 17 11:46:21 2018 +0000
@@ -24,8 +24,10 @@
 		-- Find the 'level' of the top-most function (0 == current level, 1 == caller, ...)
 		while debug.getinfo(thread, level, "") do level = level + 1; end
 		ok, runner = debug.getlocal(thread, level-1, 1);
-		assert(ok == "self", "unexpected async state: variable mismatch");
-		assert(runner.thread == thread, "unexpected async state: thread mismatch");
+		if ok ~= "self" or runner.thread ~= thread then
+			log("warn", "unexpected async state: unable to locate runner during error handling, got %s", ok);
+			return false;
+		end
 		local error_handler = runner.watchers.error;
 		if error_handler then error_handler(runner, debug.traceback(thread, err)); end
 		local ready_handler = runner.watchers.ready;