before:
stack traceback: [string "text.lua"]:9: in function 'draw' [string "edit.lua"]:200: in function 'draw' [string "run.lua"]:140: in function 'draw' [string "main.lua"]:162: in function <[string "main.lua"]:155> [C]: in function 'xpcall' [string "app.lua"]:38: in function <[string "app.lua"]:20> [C]: in function 'xpcall' [love "boot.lua"]:370: in function <[love "boot.lua"]:337>
after:
stack traceback: text.lua:9: in function 'draw' edit.lua:200: in function 'draw' run.lua:140: in function 'draw' main.lua:162: in function <[string "main.lua"]:155> [C]: in function 'xpcall' app.lua:38: in function <[string "app.lua"]:20> [C]: in function 'xpcall' [love "boot.lua"]:370: in function <[love "boot.lua"]:337>
NLU6BXIRLLAEMZUKPWIL66WWDXB3RQVAPXPXPWO7KCR2YIIKEGFAC
-- I tend to read code from files myself (say using love.filesystem calls)
-- rather than offload that to load().
-- Functions compiled in this manner have ugly filenames of the form [string "filename"]
-- This function cleans out this cruft from error callstacks.
function clean_up_callstack(callstack)
local frames = {}
print(callstack)
for frame in string.gmatch(callstack, '[^\n]+\n*') do
local line = frame:gsub('^%s*(.-)\n?$', '%1')
local filename, rest = line:match('([^:]*):(.*)')
local core_filename = filename:match('^%[string "(.*)"%]$')
-- pass through frames that don't match this format
-- this includes the initial line "stack traceback:"
local new_frame = (core_filename or filename)..':'..rest
table.insert(frames, new_frame)
end
-- the initial "stack traceback:" line was unindented and remains so
return table.concat(frames, '\n\t')
end