diff options
Diffstat (limited to 'chickadee/game-loop.scm')
-rw-r--r-- | chickadee/game-loop.scm | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/chickadee/game-loop.scm b/chickadee/game-loop.scm index 76e649a..d0bd287 100644 --- a/chickadee/game-loop.scm +++ b/chickadee/game-loop.scm @@ -26,17 +26,19 @@ ;;; (define (call-with-error-handling handler thunk) + "Call THUNK and respond to any exceptions with HANDLER. Return #t if +an error was handled." (if handler (let ((stack #f)) - (catch #t - (lambda () - (thunk) - #f) - (lambda (key . args) - (handler stack key args) - #t) - (lambda (key . args) - (set! stack (make-stack #t 3))))) + (define (pre-unwind-handler . args) + (set! stack (make-stack #t 4))) + (define (throw-handler) + (with-throw-handler #t thunk pre-unwind-handler) + #f) + (define (exception-handler e) + (handler e stack) + #t) + (with-exception-handler exception-handler throw-handler #:unwind? #t)) (begin (thunk) #f))) @@ -44,9 +46,6 @@ (define-syntax-rule (with-error-handling handler body ...) (call-with-error-handling handler (lambda () body ...))) -(define (default-error-handler stack key args) - (apply throw key args)) - ;;; ;;; Game loop kernel |