before:
Error: [string "on.draw"]:1: attempt to perform arithmetic on global 'bar' (a nil value) stack traceback: [string "on.draw"]:1: in function 'draw' main.lua:327: in function 'draw' main.lua:440: in function <main.lua:422> [C]: in function 'xpcall' main.lua:414: in function <main.lua:413> [C]: in function 'xpcall'
after:
Error: on.draw:1: attempt to perform arithmetic on global 'bar' (a nil value) stack traceback: on.draw:1: in function 'draw' main.lua:327: in function 'draw' main.lua:440: in function <main.lua:422> [C]: in function 'xpcall' main.lua:414: in function <main.lua:413> [C]: in function 'xpcall' [love "boot.lua"]:370: in function <[love "boot.lua"]:337>
5EU7N6E6XAIFJ5Q4ZLBPZADPH6Q2EZH3FBYNCBHBP7Y62O7CGKOAC local stack_trace = debug.traceback('Error: ' .. tostring(err), --[[stack frame]]2):gsub('\n[^\n]+$', '')app.send_run_time_error(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)app.send_run_time_error(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*') dotable.insert(frames, cleaned_up_frame(frame))end-- the initial "stack traceback:" line was unindented and remains soreturn table.concat(frames, '\n\t')endfunction cleaned_up_frame(frame)local line = frame:gsub('^%s*(.-)\n?$', '%1')local filename, rest = line:match('([^:]*):(.*)')return cleaned_up_filename(filename)..':'..restendfunction 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 filenameslocal _, core_filename2 = core_filename:match('^(%d+)-(.+)')return core_filename2 or core_filenameend