# HG changeset patch # User Kim Alvefur # Date 1572643835 -3600 # Node ID 955e54e451dc674fda61a72d6c7d3b9c4e79c10e # Parent 0ea7b47690961ebeb69492b6da80f562d2636617 net.http.server: Handle util.error objects from http handlers diff -r 0ea7b4769096 -r 955e54e451dc net/http/server.lua --- 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