[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Help with error handler
- From: Max Ischenko <max@...>
- Date: Mon, 22 Oct 2001 16:04:09 +0300
I'm trying to write user-friendly reportying of Lua error.
want to print stack trace to the screen and also to log file.
When using code shown below, stack trace do not saved to logfile.
I'm sure that is because _ERRORMESSAGE does some extra formatting.
How can I print stack trace to dump_error() ?
std_error_handler = _ERRORMESSAGE
safe_call_handler = function(errstr)
F("While %s", EMSG)
local s = format("While %s: %s", EMSG, errstr)
dump_error(s) -- this won't print stack trace
std_error_handler(errstr) -- this one prints stack trace
EMSG = nil
end
safe_call = function(func, emsg, ...)
EMSG = emsg
return call(func, arg, 'x', safe_call_handler)
end
function dump_error(s)
local fd = openfile("/tmp/LDUMP", "w")
write(fd, s)
write(fd, "\n")
closefile(fd)
end
--
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.