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 | c53b66920be43a25f5b5a4c65144bf011407dbf9 (patch) | |
tree | 68b91a9845650e43cf828828fbbd91ea6cf79b9d | |
parent | 2cd169874e8404f3a4c87855558a7bc7c7709c14 (diff) | |
download | prosody-c53b66920be43a25f5b5a4c65144bf011407dbf9.tar.gz prosody-c53b66920be43a25f5b5a4c65144bf011407dbf9.zip |
net.http.server: Handle util.error objects from http handlers
-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 |