# HG changeset patch # User Kim Alvefur # Date 1576351724 -3600 # Node ID e8186aba15832f3f351d885a2846ee48b536083f # Parent 493cbfe99b64232305b1814152e6635582d94f84 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. diff -r 493cbfe99b64 -r e8186aba1583 net/http/server.lua --- a/net/http/server.lua Tue Dec 10 17:43:26 2019 +0100 +++ b/net/http/server.lua Sat Dec 14 20:28:44 2019 +0100 @@ -191,7 +191,7 @@ 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); diff -r 493cbfe99b64 -r e8186aba1583 util/error.lua --- a/util/error.lua Tue Dec 10 17:43:26 2019 +0100 +++ b/util/error.lua Sat Dec 14 20:28:44 2019 +0100 @@ -21,7 +21,7 @@ type = template.type or "cancel"; condition = template.condition or "undefined-condition"; text = template.text; - code = template.code or 500; + code = template.code; context = context or template.context or { _error_id = e }; }, error_mt);