scansion/error.lua

Thu, 23 Mar 2023 12:14:53 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 23 Mar 2023 12:14:53 +0000
changeset 172
2c17151ed21b
parent 111
25530dccf696
permissions
-rw-r--r--

client: Fix timeout handling

Previously, the timeout handler would fire an error that would get caught and
logged by the timer code. However that error never reached the upper levels of
scansion, leading to the whole thing just hanging.

Now we just trigger resumption of the async runner, and throw the error from
there if we haven't received the stanza yet.

With this change, timeouts are now correctly handled and reported as failures.

local error_mt = {
	__tostring = function (e)
		return tostring(e.text or e.type or ("<Scansion error: "..tostring(e)..">"));
	end;
	__name = "scansion error";
};

return {
	new_error = function (type, data)
		return setmetatable({ type = type, text = data.text, data = data }, error_mt);
	end;
	is = function (err)
		return getmetatable(err) == error_mt;
	end;
};

mercurial