attempt at better error recovery

[?]
Apr 20, 2023, 6:23 AM
K7ABD3WDOLPPQOQGDVMTMEIHDAPOTMHPEL65XEGBITIW4MHVH75QC

Dependencies

  • [2] BXXTVMBQ better organization of errors
  • [3] 5PC2IJZA backport some improvements from template-live-editor
  • [4] 5UT4ZUMM remove a local
  • [5] IOGZEHCW document available modes
  • [6] JUTECG5X bring template-live's protocol in sync with template-live-editor
  • [7] ZFLAXEIJ drop non-existent arg in callback
  • [8] TK4G4GMC expose a command for the driver to remotely restart an app
  • [9] 4H4JTSFI mouse wheel support
  • [10] TNRO6KLZ new live app
  • [11] OJLXS67N a prefix for metadata in the manifest
  • [12] EY6UKABA record support for multiple versions
  • [13] UUX7J2OA prevent overriding foundational definitions
  • [14] NTOJPPQN move temporary file out of user directory (if possible)

Change contents

  • replacement in main.lua at line 22
    [6.3][5.2:41](),[5.41][6.3:26](),[6.3][6.3:26]()
    -- available modes: run, version_check
    Mode = 'version_check'
    [6.3]
    [6.26]
    -- available modes: run, error
    Mode = 'run'
    Error_message = nil
    Error_count = 0
    -- we'll reuse error mode on load for an initial version check
  • edit in main.lua at line 42
    [6.1040]
    [6.145]
    -- version check
  • replacement in main.lua at line 45
    [6.216][6.216:283]()
    if array.find(Supported_versions, Version) then
    Mode = 'run'
    [6.216]
    [6.283]
    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
  • edit in main.lua at line 120
    [6.4432]
    [6.4432]
    -- listen for commands in both 'error' and 'run' modes
  • edit in main.lua at line 125
    [6.4550]
    [6.1]
    Mode = 'run'
  • replacement in main.lua at line 130
    [6.4605][6.4605:4643]()
    if on.update then on.update(dt) end
    [6.4605]
    [6.4643]
    if Mode == 'run' then
    if on.update then on.update(dt) end
    end
  • replacement in main.lua at line 315
    [6.8572][6.377:411]()
    if Mode == 'version_check' then
    [6.8572]
    [6.411]
    if Mode == 'error' then
  • replacement in main.lua at line 319
    [6.533][6.533:719]()
    love.graphics.print(("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)
    [6.533]
    [6.719]
    love.graphics.printf(Error_message, 40, 40, 600)
  • replacement in main.lua at line 326
    [6.8630][6.737:782]()
    if Mode == 'version_check' then return end
    [6.8630]
    [6.8630]
    if Mode == 'error' then return end
  • replacement in main.lua at line 336
    [6.8693][6.783:828]()
    if Mode == 'version_check' then return end
    [6.8693]
    [6.8693]
    if Mode == 'error' then return end
  • replacement in main.lua at line 343
    [6.8829][6.829:874]()
    if Mode == 'version_check' then return end
    [6.8829]
    [6.8829]
    if Mode == 'error' then return end
  • replacement in main.lua at line 348
    [6.8910][6.875:920]()
    if Mode == 'version_check' then return end
    [6.8910]
    [6.8910]
    if Mode == 'error' then return end
  • replacement in main.lua at line 356
    [6.9075][6.921:966]()
    if Mode == 'version_check' then return end
    [6.9075]
    [6.9075]
    if Mode == 'error' then
    if key == 'c' then
    love.system.setClipboardText(Error_message)
    end
    return
    end
  • replacement in main.lua at line 370
    [6.9319][6.967:1012]()
    if Mode == 'version_check' then return end
    [6.9319]
    [6.9319]
    if Mode == 'error' then return end
  • replacement in main.lua at line 379
    [6.42][6.1013:1047]()
    if Mode == 'version_check' then
    [6.42]
    [6.1047]
    if Mode == 'error' then
  • replacement in main.lua at line 387
    [6.9683][6.1082:1127]()
    if Mode == 'version_check' then return end
    [6.9683]
    [6.405]
    if Mode == 'error' then return end
  • replacement in main.lua at line 392
    [6.9800][6.1128:1173]()
    if Mode == 'version_check' then return end
    [6.9800]
    [6.469]
    if Mode == 'error' then return end
  • replacement in main.lua at line 397
    [6.41][6.1174:1219]()
    if Mode == 'version_check' then return end
    [6.41]
    [6.41]
    if Mode == 'error' then return end
  • replacement in main.lua at line 445
    [6.10991][6.10991:11256]()
    -- 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
    [6.10963]
    [4.2]
    Mode = 'error'
  • edit in main.lua at line 447
    [4.110][6.11364:11642](),[6.11364][6.11364:11642]()
    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
  • replacement in main.lua at line 448
    [2.330][6.11676:11721](),[6.11676][6.11676:11721](),[6.11721][3.257:285](),[3.285][6.11721:11773](),[6.11721][6.11721:11773]()
    local buf
    repeat
    buf = app.receive()
    love.timer.sleep(0.001)
    until buf
    if buf == 'QUIT' then
    return true
    [2.330]
    [6.11773]
    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 "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 main.lua at line 458
    [6.11779][6.11779:11794]()
    app.run(buf)
    [6.11779]
    [6.11794]
    print(Error_message)