Software /
code /
prosody
Changeset
4777:74ae0433f8dd
util.debug: Re-fix parameter handling (I think it matches debug.traceback() more accurately now) and document level fudge
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 28 Apr 2012 16:20:26 +0100 |
parents | 4776:dbe9d75c0452 |
children | 4778:127de6eec433 |
files | util/debug.lua |
diffstat | 1 files changed, 16 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/util/debug.lua Sat Apr 28 15:47:43 2012 +0100 +++ b/util/debug.lua Sat Apr 28 16:20:26 2012 +0100 @@ -119,21 +119,26 @@ 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;