Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving Lua error messages

Tags:

debugging

lua

Whenever an error occurs in a Lua script, I'd like it to write the values of all local and global variables to the screen/optionally to a file - in addition to the usual stack trace.

How could I get this to be the default behavior for all errors?

like image 259
proFromDover Avatar asked Jul 18 '10 16:07

proFromDover


1 Answers

If you're using the standard Lua interpreter, replace debug.traceback with your own function. If you're embedding Lua in your program, use your traceback function in lua_pcall.

like image 161
lhf Avatar answered Oct 10 '22 02:10

lhf