Comparison

net/http/server.lua @ 5505:0b6a99e6c1b1

mod_c2s, mod_s2s, net.http, net.http.server: Improve tracebacks (omit traceback function), to make it clearer where an error occured
author Matthew Wild <mwild1@gmail.com>
date Mon, 22 Apr 2013 12:35:52 +0100
parent 5504:b760b5f0c2b0
child 5754:dee0f05ccf70
comparison
equal deleted inserted replaced
5504:b760b5f0c2b0 5505:0b6a99e6c1b1
7 local os_date = os.date; 7 local os_date = os.date;
8 local pairs = pairs; 8 local pairs = pairs;
9 local s_upper = string.upper; 9 local s_upper = string.upper;
10 local setmetatable = setmetatable; 10 local setmetatable = setmetatable;
11 local xpcall = xpcall; 11 local xpcall = xpcall;
12 local debug = debug; 12 local traceback = debug.traceback;
13 local tostring = tostring; 13 local tostring = tostring;
14 local codes = require "net.http.codes"; 14 local codes = require "net.http.codes";
15 15
16 local _M = {}; 16 local _M = {};
17 17
86 local handle_request; 86 local handle_request;
87 local _1, _2, _3; 87 local _1, _2, _3;
88 local function _handle_request() return handle_request(_1, _2, _3); end 88 local function _handle_request() return handle_request(_1, _2, _3); end
89 89
90 local last_err; 90 local last_err;
91 local function _traceback_handler(err) last_err = err; log("error", "Traceback[http]: %s: %s", tostring(err), debug.traceback()); end 91 local function _traceback_handler(err) last_err = err; log("error", "Traceback[httpserver]: %s", traceback(tostring(err), 2)); end
92 events.add_handler("http-error", function (error) 92 events.add_handler("http-error", function (error)
93 return "Error processing request: "..codes[error.code]..". Check your error log for more information."; 93 return "Error processing request: "..codes[error.code]..". Check your error log for more information.";
94 end, -1); 94 end, -1);
95 95
96 function listener.onconnect(conn) 96 function listener.onconnect(conn)