Software /
code /
prosody
Changeset
10501:e8186aba1583
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 14 Dec 2019 20:28:44 +0100 |
parents | 10500:493cbfe99b64 |
children | 10502:f1c0aa521dd5 |
files | net/http/server.lua util/error.lua |
diffstat | 2 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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);