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
commitc53b66920be43a25f5b5a4c65144bf011407dbf9 (patch)
tree68b91a9845650e43cf828828fbbd91ea6cf79b9d /net/http
parent2cd169874e8404f3a4c87855558a7bc7c7709c14 (diff)
downloadprosody-c53b66920be43a25f5b5a4c65144bf011407dbf9.tar.gz
prosody-c53b66920be43a25f5b5a4c65144bf011407dbf9.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