aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/mod_admin_adhoc.lua2
-rw-r--r--util/debug.lua29
2 files changed, 18 insertions, 13 deletions
diff --git a/plugins/mod_admin_adhoc.lua b/plugins/mod_admin_adhoc.lua
index 6f1357a9..4d2c60d7 100644
--- a/plugins/mod_admin_adhoc.lua
+++ b/plugins/mod_admin_adhoc.lua
@@ -24,7 +24,7 @@ local dataforms_new = require "util.dataforms".new;
local array = require "util.array";
local modulemanager = require "modulemanager";
-module:depends"adhoc";
+module:depends("adhoc");
local adhoc_new = module:require "adhoc".new;
function add_user_command_handler(self, data, state)
diff --git a/util/debug.lua b/util/debug.lua
index 1d3b5648..bff0e347 100644
--- a/util/debug.lua
+++ b/util/debug.lua
@@ -97,7 +97,7 @@ function get_traceback_table(thread, start_level)
levels[(level-start_level)+1] = {
level = level;
info = info;
- locals = get_locals_table(level);
+ locals = get_locals_table(level+1);
upvalues = get_upvalues_table(info.func);
};
end
@@ -119,21 +119,26 @@ end
function _traceback(thread, message, level)
- if type(thread) ~= "thread" then
+ -- Lua manual says: debug.traceback ([thread,] [message [, level]])
+ -- I fathom this to mean one of:
+ -- ()
+ -- (thread)
+ -- (message, level)
+ -- (thread, message, level)
+
+ if thread == nil then -- Defaults
+ thread, message, level = coroutine.running(), message, level;
+ elseif type(thread) == "string" then
thread, message, level = coroutine.running(), thread, message;
+ elseif type(thread) ~= "thread" then
+ return nil; -- debug.traceback() does this
end
- if level and type(message) ~= "string" then
- return nil, "invalid message";
- elseif not level then
- if type(message) == "number" then
- level, message = message, nil;
- else
- level = 1;
- end
- end
-
+
+ level = level or 1;
+
message = message and (message.."\n") or "";
+ -- +3 counts for this function, and the pcall() and wrapper above us
local levels = get_traceback_table(thread, level+3);
local last_source_desc;