c257139d17
When an error occurs in a mode handler, change to error-mode. Within error-mode, display the traceback and allow the user to exit, (which the default love error handler does) but also allows returning back to the previous mode. The assumption is that this would be done after using the repl to ,reload the module containing the bug which caused the error.
31 lines
888 B
Fennel
31 lines
888 B
Fennel
;; This mode has two purposes:
|
|
;; * display the stack trace that caused the error
|
|
;; * allow the user to decide whether to retry after reloading or quit
|
|
|
|
;; Since we can't know which module needs to be reloaded, we rely on the user
|
|
;; doing a ,reload foo in the repl.
|
|
|
|
(var state nil)
|
|
|
|
(local explanation "Press escape to quit.
|
|
Press space to return to the previous mode after reloading in the repl.")
|
|
|
|
(fn draw []
|
|
(love.graphics.clear 0.34 0.61 0.86)
|
|
(love.graphics.setColor 0.9 0.9 0.9)
|
|
(love.graphics.print state.msg 10 10)
|
|
(love.graphics.print explanation 15 25)
|
|
(love.graphics.print state.traceback 15 50))
|
|
|
|
(fn keypressed [key set-mode]
|
|
(match key
|
|
:escape (love.event.quit)
|
|
:space (set-mode state.old-mode)))
|
|
|
|
(fn activate [old-mode msg traceback]
|
|
(print msg)
|
|
(print traceback)
|
|
(set state {: old-mode : msg : traceback}))
|
|
|
|
{: draw : keypressed : activate}
|