attempt at better error recovery

[?]
Apr 20, 2023, 7:30 AM
T7QIIGQ6YYTTYCVHVEAZSUQ3O4LYBHGPFL4K6D5TA4BA7PND4EJQC

Dependencies

  • [2] JNVN64RG stop cranking CPU on error
  • [3] 45BU7IRV remove a local
  • [4] QMSYY47G Merge text0
  • [5] KWIIU3KR document available modes
  • [6] KVHUFUFV reorg
  • [7] JOPVPUSA editing source code from within the app
  • [8] TBWAE64A app is now live, can communicate with driver
  • [9] BSDXVB3H backport some doc updates and renames
  • [10] XGHCLIKB Merge lines.love
  • [11] ZNLTRNNK highlight another global
  • [12] LNUHQOGH start passing in Editor_state explicitly
  • [13] RT6EV6OP delegate update events to drawings
  • [14] D6T6FIO4 unnecessary coercion
  • [15] 2RWR3GM4 another missed rename
  • [16] OLX2RRDI Merge text0
  • [17] LXFHXL2N Merge text.love
  • [18] PJ5PQAQE record support for multiple versions
  • [19] Z4XRNDTR find text
  • [20] 5FW7YOFT highlight selection while dragging
  • [21] UH4YWHW5 button framework is at the app level
  • [22] TXDMRA5J bugfix: alt-tab shouldn't emit keypress events
  • [23] LRDM35CE app running again
  • [24] ORKN6EOB Merge lines.love
  • [25] KKMFQDR4 editing source code from within the app
  • [26] JCSLDGAH beginnings of support for multiple shapes
  • [27] K464QQR4 more defensive resize handling
  • [28] AVTNUQYR basic test-enabled framework
  • [29] AVLAYODP much simpler
  • [30] 2L5MEZV3 experiment: new edit namespace
  • [31] SDRXK4X5 move
  • [32] PP2IIHL6 stop putting button state in a global
  • [33] OTIBCAUJ love2d scaffold
  • [34] APX2PY6G stop tracking wallclock time
  • [35] 3QQZ7W4E bring couple more globals back to the app level
  • [36] VP5KC4XZ Merge lines.love
  • [37] IM6GSGVZ fix some arg names
  • [38] WZZGVKSG a few more renames
  • [39] J2SVGR2E experiment: blinking cursor
  • [40] 2CTN2IEF Merge lines.love
  • [41] BYG5CEMV support for naming points
  • [42] 6VXO3ZL3 just keep the cursor visible after any input events
  • [43] 36Z442IV back to commit 8123959e52f without code editing
  • [44] CYGNFOA5 Merge text0

Change contents

  • replacement in main.lua at line 16
    [6.38][5.8:49](),[5.49][6.38:63](),[6.38][6.38:63]()
    -- available modes: run, version_check
    Mode = 'version_check'
    [6.38]
    [6.63]
    -- available modes: run, error
    Mode = 'run'
    Error_message = nil
    Error_count = 0
    -- we'll reuse error mode on load for an initial version check
  • replacement in main.lua at line 24
    [6.240][6.240:307]()
    if array.find(Supported_versions, Version) then
    Mode = 'run'
    [6.240]
    [6.307]
    if array.find(Supported_versions, Version) == nil then
    Mode = 'error'
    Error_message = ("This app doesn't support version %s; please use version %s. Press any key to try it with this version anyway."):format(Version, Supported_versions[1])
    print(Error_message)
    -- continue initializing everything; hopefully we won't have errors during initialization
  • replacement in main.lua at line 148
    [6.1373][6.319:664]()
    if Mode == 'version_check' then
    love.graphics.setColor(1,1,0)
    love.graphics.rectangle('fill', 30,30, 400,400)
    love.graphics.setColor(0,0,0)
    love.graphics.printf(("This app doesn't support version %s; please use version %s. Press any key to try it with this version anyway."):format(Version, Supported_versions[1]), 40,40, 400)
    [6.1373]
    [6.664]
    if Mode == 'error' then
    love.graphics.setColor(0,0,1)
    love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
    love.graphics.setColor(1,1,1)
    love.graphics.printf(Error_message, 40,40, 600)
  • replacement in main.lua at line 159
    [6.1398][6.682:727]()
    if Mode == 'version_check' then return end
    [6.1398]
    [6.486]
    if Mode == 'error' then return end
  • edit in main.lua at line 166
    [6.6105]
    [6.7]
    -- listen for commands in both 'error' and 'run' modes
  • replacement in main.lua at line 168
    [6.25][6.225:263](),[6.6105][6.225:263]()
    if on.update then on.update(dt) end
    [6.25]
    [6.6137]
    if Mode == 'run' then
    if on.update then on.update(dt) end
    end
  • replacement in main.lua at line 174
    [6.6820][6.774:819]()
    if Mode == 'version_check' then return end
    [6.6820]
    [6.6820]
    if Mode == 'error' then return end
  • replacement in main.lua at line 180
    [6.7006][6.820:865]()
    if Mode == 'version_check' then return end
    [6.7006]
    [6.7006]
    if Mode == 'error' then return end
  • replacement in main.lua at line 186
    [6.39][6.866:911]()
    if Mode == 'version_check' then return end
    [6.39]
    [6.39]
    if Mode == 'error' then return end
  • replacement in main.lua at line 192
    [6.7176][6.912:957]()
    if Mode == 'version_check' then return end
    [6.7176]
    [6.7176]
    if Mode == 'error' then return end
  • replacement in main.lua at line 207
    [6.8173][6.958:1003]()
    if Mode == 'version_check' then return end
    [6.8173]
    [6.188176]
    if Mode == 'error' then
    if chord == 'C-c' then
    love.system.setClipboardText(Error_message)
    end
    return
    end
  • replacement in main.lua at line 222
    [6.1512][6.1004:1049]()
    if Mode == 'version_check' then return end
    [6.1512]
    [6.189334]
    if Mode == 'error' then return end
  • replacement in main.lua at line 232
    [6.57][6.1050:1084]()
    if Mode == 'version_check' then
    [6.57]
    [6.1084]
    if Mode == 'error' then
  • replacement in live.lua at line 299
    [6.9968][6.9968:10233](),[6.10233][3.9:115](),[6.105][6.10341:10619](),[3.115][6.10341:10619](),[6.10341][6.10341:10619]()
    -- draw a pause indicator on screen
    love.graphics.setColor(1,0,0)
    love.graphics.rectangle('fill', 10,10, 3,10)
    love.graphics.rectangle('fill', 16,10, 3,10)
    love.graphics.present()
    -- print stack trace here just in case we ran the app through a terminal
    local stack_trace = debug.traceback('Error: '..tostring(err), --[[stack frame]]2):gsub('\n[^\n]+$', '')
    print(stack_trace)
    print('Look in the driver for options to investigate further.')
    print("(You probably can't close the app window at this point. If you don't have the driver set up, you might need to force-quit.)")
    -- send stack trace to driver and wait for a response
    [6.9940]
    [6.976]
    Mode = 'error'
    local stack_trace = debug.traceback('Error: ' .. tostring(err), --[[stack frame]]2):gsub('\n[^\n]+$', '')
  • replacement in live.lua at line 302
    [6.659][6.10654:10675](),[6.1026][6.10654:10675](),[6.10654][6.10654:10675](),[6.10675][6.1027:1064](),[6.1064][2.9:37](),[2.37][6.10700:10752](),[6.1064][6.10700:10752](),[6.10700][6.10700:10752]()
    local buf
    repeat
    buf = live.receive_from_driver()
    love.timer.sleep(0.001)
    until buf
    if buf == 'QUIT' then
    return true
    [6.1026]
    [6.10752]
    Error_message = 'Something is wrong. Sorry!\n\n'..stack_trace..'\n\n'..
    "(Note: function names above don't include outer tables. So functions like on.draw might show up as just 'draw', etc.)\n\n"..
    'Options:\n'..
    '- press "ctrl+c" (without the quotes) to copy this message to your clipboard to send to me: ak@akkartik.com\n'..
    '- press any other key to retry, see if things start working again\n'..
    '- run driver.love to try to fix it yourself. As you do, feel free to ask me questions: ak@akkartik.com\n'
    Error_count = Error_count+1
    if Error_count > 1 then
    Error_message = Error_message..('\n\nThis is error #%d in this session; things will probably not improve in this session. Please copy the message and send it to me: ak@akkartik.com.'):format(Error_count)
  • replacement in live.lua at line 312
    [6.10758][6.10758:10774]()
    live.run(buf)
    [6.10758]
    [6.10774]
    print(Error_message)