Diff

net/http/server.lua @ 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
parent 10396:3278f2a31a0a
child 10719:977c9883f625
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);