I've tested both syntax error and run-time error flows.
BQH7ANWMOV3WODWYEC2AH4QGBMJRNIO2TAHHQBYHVXYWJKDZLG6AC
3BRGOF7NV52C3CY6HLGH53TDW2OHRQYQHWBEA3P6BKCUTN5DVHQQC
XJEVMWTSLXWFQ2JPCFWZ3Q46OFXZEX64OL7O6C2SCWCI4OPKSOPAC
AFZEVZOUY7ECADAHNU3C6OGJCA2MJQCK3JQZOFDVKXMBILBAH2JAC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
BSDXVB3HU5Y5FZ244FU2F577RTM6SWEHAZX3IELBVUP52CRFVDSAC
T7QIIGQ6YYTTYCVHVEAZSUQ3O4LYBHGPFL4K6D5TA4BA7PND4EJQC
AGJXIDOFAZEKPSGDVZJAZXNOKQLTVZUKOCIYFN4AB4YEWVRFRNRAC
TBWAE64A6IIDDXKB6LXDI6WQYAAUYP2QRH3KLM3PUILMVL2BFTTAC
3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC
NLU6BXIRLLAEMZUKPWIL66WWDXB3RQVAPXPXPWO7KCR2YIIKEGFAC
R6MB3UPBWL3PYRPVDCJFJIYGIJUV4ALGYUIGKGD3BZXCIAE6R5CQC
local stack_trace = debug.traceback('Error: ' .. tostring(err), --[[stack frame]]2)
live.send_run_time_error_to_driver(stack_trace)
Error_message = 'Something is wrong. Sorry!\n\n'..stack_trace..'\n\n'..
local callstack = debug.traceback('', --[[stack frame]]2)
local cleaned_up_error = 'Error: ' .. cleaned_up_frame(tostring(err))..'\n'..cleaned_up_callstack(callstack)
live.send_run_time_error_to_driver(cleaned_up_error)
Error_message = 'Something is wrong. Sorry!\n\n'..cleaned_up_error..'\n\n'..
-- 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.
-- It also strips out the numeric prefixes we introduce in filenames.
function cleaned_up_callstack(callstack)
local frames = {}
for frame in string.gmatch(callstack, '[^\n]+\n*') do
table.insert(frames, cleaned_up_frame(frame))
end
-- the initial "stack traceback:" line was unindented and remains so
return table.concat(frames, '\n\t')
end
function cleaned_up_frame(frame)
local line = frame:gsub('^%s*(.-)\n?$', '%1')
local filename, rest = line:match('([^:]*):(.*)')
return cleaned_up_filename(filename)..':'..rest
end
function cleaned_up_filename(filename)
-- pass through frames that don't match this format
-- this includes the initial line "stack traceback:"
local core_filename = filename:match('^%[string "(.*)"%]$')
if core_filename == nil then return filename end
-- strip out the numeric prefixes we introduce in filenames
local _, core_filename2 = core_filename:match('^(%d+)-(.+)')
return core_filename2 or core_filename
end