Changeset

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
parents 5504:b760b5f0c2b0
children 5510:3758898cefdd
files net/http.lua net/http/server.lua plugins/mod_c2s.lua plugins/mod_s2s/mod_s2s.lua
diffstat 4 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/net/http.lua	Mon Apr 22 12:25:00 2013 +0100
+++ b/net/http.lua	Mon Apr 22 12:35:52 2013 +0100
@@ -17,9 +17,9 @@
 local server = require "net.server"
 
 local t_insert, t_concat = table.insert, table.concat;
-local pairs, ipairs = pairs, ipairs;
-local tonumber, tostring, xpcall, select, debug_traceback, char, format =
-      tonumber, tostring, xpcall, select, debug.traceback, string.char, string.format;
+local pairs = pairs;
+local tonumber, tostring, xpcall, select, traceback =
+      tonumber, tostring, xpcall, select, debug.traceback;
 
 local log = require "util.logger".init("http");
 
@@ -101,7 +101,7 @@
 	request.parser:feed(data);
 end
 
-local function handleerr(err) log("error", "Traceback[http]: %s: %s", tostring(err), debug_traceback()); end
+local function handleerr(err) log("error", "Traceback[http]: %s", traceback(tostring(err), 2)); end
 function request(u, ex, callback)
 	local req = url.parse(u);
 	
--- a/net/http/server.lua	Mon Apr 22 12:25:00 2013 +0100
+++ b/net/http/server.lua	Mon Apr 22 12:35:52 2013 +0100
@@ -9,7 +9,7 @@
 local s_upper = string.upper;
 local setmetatable = setmetatable;
 local xpcall = xpcall;
-local debug = debug;
+local traceback = debug.traceback;
 local tostring = tostring;
 local codes = require "net.http.codes";
 
@@ -88,7 +88,7 @@
 local function _handle_request() return handle_request(_1, _2, _3); end
 
 local last_err;
-local function _traceback_handler(err) last_err = err; log("error", "Traceback[http]: %s: %s", tostring(err), debug.traceback()); end
+local function _traceback_handler(err) last_err = err; log("error", "Traceback[httpserver]: %s", traceback(tostring(err), 2)); end
 events.add_handler("http-error", function (error)
 	return "Error processing request: "..codes[error.code]..". Check your error log for more information.";
 end, -1);
--- a/plugins/mod_c2s.lua	Mon Apr 22 12:25:00 2013 +0100
+++ b/plugins/mod_c2s.lua	Mon Apr 22 12:35:52 2013 +0100
@@ -116,7 +116,7 @@
 	end
 end
 
-local function handleerr(err) log("error", "Traceback[c2s]: %s: %s", tostring(err), traceback()); end
+local function handleerr(err) log("error", "Traceback[c2s]: %s", traceback(tostring(err), 2)); end
 function stream_callbacks.handlestanza(session, stanza)
 	stanza = session.filter("stanzas/in", stanza);
 	if stanza then
--- a/plugins/mod_s2s/mod_s2s.lua	Mon Apr 22 12:25:00 2013 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Mon Apr 22 12:35:52 2013 +0100
@@ -429,7 +429,7 @@
 	end
 end
 
-local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), traceback()); end
+local function handleerr(err) log("error", "Traceback[s2s]: %s", traceback(tostring(err), 2)); end
 function stream_callbacks.handlestanza(session, stanza)
 	if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
 		stanza.attr.xmlns = nil;