SnabbCo/snabbswitch — pull request #158 by lukego (2014-04-30 20:52:11+00:00)
Title: Added -S argument for better stack traces.

Uses StackTracePlus: https://github.com/ignacio/StackTracePlus

New look with -S:

$ sudo ./snabb -S -e 'assert(nil)'
[string "assert(nil)"]:1: assertion failed!
line not found

Stack Traceback
===============
(1) Lua function 'handler' at file 'core/main.lua:137' (best guess)
Local variables:
reason = string: "[string \"assert(nil)\"]:1: assertion failed!"
(*temporary) = C function: print
(2) global C function 'assert'
(3) main chunk of [string "assert(nil)"] at line 1
(4) Lua function 'main' at file 'core/main.lua:66' (best guess)
Local variables:
args = table: 0x53587ff0 {1:-S, 2:-e, 3:assert(nil)}
i = number: 2
thunk = Lua function '?' (defined at line 0 of chunk "assert(nil)"])
error = nil
(5) global C function 'xpcall'
(6) main chunk of file 'core/main.lua' at line 142
(7) global C function 'require'
(8) main chunk of [string "require "core.main""] at line 1
nil

Old look:

$ sudo ./snabb -e 'assert(nil)'
[string "assert(nil)"]:1: assertion failed!
stack traceback:
core/main.lua:137: in function
[C]: in function 'assert'
[string "assert(nil)"]:1: in function 'thunk'
core/main.lua:66: in function
[C]: in function 'xpcall'
core/main.lua:142: in main chunk
[C]: in function 'require'
[string "require "core.main""]:1: in main chunk