diff options
author | Kim Alvefur <zash@zash.se> | 2019-11-01 22:30:35 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-11-01 22:30:35 +0100 |
commit | fdfe1e0b2bf8cea4e2e512fa8e25bface008a59b (patch) | |
tree | 68b91a9845650e43cf828828fbbd91ea6cf79b9d /net | |
parent | fbab8ed06ac738e6aec96db67141f987b9d3c058 (diff) | |
download | prosody-fdfe1e0b2bf8cea4e2e512fa8e25bface008a59b.tar.gz prosody-fdfe1e0b2bf8cea4e2e512fa8e25bface008a59b.zip |
net.http.server: Handle util.error objects from http handlers
Diffstat (limited to 'net')
-rw-r--r-- | net/http/server.lua | 3 |
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 |