Software /
code /
prosody
Changeset
10394:955e54e451dc
net.http.server: Handle util.error objects from http handlers
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 01 Nov 2019 22:30:35 +0100 |
parents | 10393:0ea7b4769096 |
children | 10395:faa4fcc78b14 |
files | net/http/server.lua |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http/server.lua Fri Nov 01 22:28:39 2019 +0100 +++ b/net/http/server.lua Fri Nov 01 22:30:35 2019 +0100 @@ -13,6 +13,7 @@ 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 @@ 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