(define* (call-with-error-handling thunk #:key
(on-error 'debug) (post-error 'catch)
- (pass-keys '(quit)))
+ (pass-keys '(quit)) (trap-handler 'debug))
(let ((in (current-input-port))
(out (current-output-port))
(err (current-error-port)))
(format #t "Type `,bt' for a backtrace or `,q' to continue.\n")
((@ (system repl repl) start-repl) #:debug debug)))))
+ (define (null-trap-handler frame trap-idx trap-name)
+ #t)
+
+ (define le-trap-handler
+ (case trap-handler
+ ((debug) debug-trap-handler)
+ ((pass) null-trap-handler)
+ ((disabled) #f)
+ (else (error "Unknown trap-handler strategy" trap-handler))))
+
(catch #t
(lambda ()
- (with-default-trap-handler debug-trap-handler
+ (with-default-trap-handler le-trap-handler
(lambda () (%start-stack #t thunk))))
(case post-error
(apply throw key args)
(begin
(pmatch args
- ((,subr ,msg ,args . ,rest)
- (with-saved-ports
- (lambda ()
- (run-hook before-error-hook)
- (display-error #f err subr msg args rest)
- (run-hook after-error-hook)
- (force-output err))))
- (else
- (format err "\nERROR: uncaught throw to `~a', args: ~a\n"
- key args)))
+ ((,subr ,msg ,args . ,rest)
+ (with-saved-ports
+ (lambda ()
+ (run-hook before-error-hook)
+ (display-error #f err subr msg args rest)
+ (run-hook after-error-hook)
+ (force-output err))))
+ (else
+ (format err "\nERROR: uncaught throw to `~a', args: ~a\n"
+ key args)))
(if #f #f)))))
((catch)
(lambda (key . args)
(apply throw key args))))
(else
(if (procedure? post-error)
- post-error ; a handler proc
+ post-error ; a handler proc
(error "Unknown post-error strategy" post-error))))
(case on-error
#t))
(else
(if (procedure? on-error)
- on-error ; pre-unwind handler
+ on-error ; pre-unwind handler
(error "Unknown on-error strategy" on-error)))))))
(define-syntax with-error-handling
(with-fluids ((%default-trap-handler handler))
(dynamic-wind
(lambda ()
- (set-vm-trace-level! (the-vm) (trap-state->trace-level trap-state)))
+ ;; Don't enable hooks if the handler is #f.
+ (if handler
+ (set-vm-trace-level! (the-vm) (trap-state->trace-level trap-state))))
thunk
(lambda ()
- (set-vm-trace-level! (the-vm) 0)))))
+ (if handler
+ (set-vm-trace-level! (the-vm) 0))))))
(define* (list-traps #:optional (trap-state (the-trap-state)))
(map (lambda (wrapper)