util.error: Move default for numeric error code to net.http.server

Stanza errors can also have numbers but these are a legacy thing and
rarely used, except in MUC. HTTP errors on the other hand always have a
number.
This commit is contained in:
Kim Alvefur 2019-12-14 20:28:44 +01:00
parent ffcb8303cc
commit 87d0125802
2 changed files with 2 additions and 2 deletions

View file

@ -191,7 +191,7 @@ local function handle_result(request, response, result)
elseif result_type == "string" then
body = result;
elseif errors.is_err(result) then
body = events.fire_event("http-error", { request = request, response = response, code = result.code, error = result });
body = events.fire_event("http-error", { request = request, response = response, code = result.code or 500, error = result });
elseif promise.is_promise(result) then
result:next(function (ret)
handle_result(request, response, ret);