− end
− end
−
− local callstack = debug.traceback('', --[[stack frame]]2)
− Error_message = 'Error: ' .. tostring(err)..'\n'..clean_up_callstack(callstack)
− -- 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)