diff options
-rw-r--r-- | chickadee.scm | 28 | ||||
-rw-r--r-- | chickadee/sdl.scm | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/chickadee.scm b/chickadee.scm index 74faa56..f6894b0 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -16,8 +16,7 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee) - #:export (default-error-handler - run-game + #:export (run-game abort-game)) @@ -26,16 +25,20 @@ ;;; (define (call-with-error-handling handler thunk) - (let ((stack #f)) - (catch #t - (lambda () + (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))))) + (begin (thunk) - #f) - (lambda (key . args) - (handler stack key args) - #t) - (lambda (key . args) - (set! stack (make-stack #t 3)))))) + #f))) (define-syntax-rule (with-error-handling handler body ...) (call-with-error-handling handler (lambda () body ...))) @@ -53,8 +56,7 @@ (define (abort-game) (abort-to-prompt game-loop-prompt-tag #f)) -(define* (run-game #:key update render time - (error default-error-handler) +(define* (run-game #:key update render time error (update-hz 60)) (let ((timestep (round (/ 1000 update-hz)))) (call-with-prompt game-loop-prompt-tag diff --git a/chickadee/sdl.scm b/chickadee/sdl.scm index b00e30e..948b351 100644 --- a/chickadee/sdl.scm +++ b/chickadee/sdl.scm @@ -85,7 +85,7 @@ (controller-press (const #t)) (controller-release (const #t)) (controller-move (const #t)) - (error default-error-handler)) + error) (sdl-init) (false-if-exception (mixer-init)) (open-audio) |