aboutsummaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-01 22:30:35 +0100
committerKim Alvefur <zash@zash.se>2019-11-01 22:30:35 +0100
commitfdfe1e0b2bf8cea4e2e512fa8e25bface008a59b (patch)
tree68b91a9845650e43cf828828fbbd91ea6cf79b9d /net/http
parentfbab8ed06ac738e6aec96db67141f987b9d3c058 (diff)
downloadprosody-fdfe1e0b2bf8cea4e2e512fa8e25bface008a59b.tar.gz
prosody-fdfe1e0b2bf8cea4e2e512fa8e25bface008a59b.zip
net.http.server: Handle util.error objects from http handlers
Diffstat (limited to 'net/http')
-rw-r--r--net/http/server.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/http/server.lua b/net/http/server.lua
index 0682d6ed..0d49dbce 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -13,6 +13,7 @@ local traceback = debug.traceback;
local tostring = tostring;
local cache = require "util.cache";
local codes = require "net.http.codes";
+local errors = require "util.error";
local blocksize = 2^16;
local _M = {};
@@ -188,6 +189,8 @@ local function handle_result(request, response, result)
end
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 });
elseif result_type == "table" then
for k, v in pairs(result) do
if k ~= "headers" then