diff --git a/knots/resource-pool.scm b/knots/resource-pool.scm index 8bfef2b..f4522be 100644 --- a/knots/resource-pool.scm +++ b/knots/resource-pool.scm @@ -129,18 +129,16 @@ (lambda () (let ((new-resource (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception adding resource to pool ~A: ~A:\n ~A\n" - name - return-new-resource - exn) - #f) + (lambda _ #f) (lambda () (with-exception-handler (lambda (exn) - (backtrace) + (simple-format + (current-error-port) + "exception adding resource to pool ~A: ~A\n\n" + name + return-new-resource) + (print-backtrace-and-exception/knots exn) (raise-exception exn)) (lambda () (start-stack #t (return-new-resource))))) @@ -155,18 +153,16 @@ (let loop () (let ((success? (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception running resource pool destructor (~A): ~A:\n ~A\n" - name - destructor - exn) - #f) + (lambda _ #f) (lambda () (with-exception-handler (lambda (exn) - (backtrace) + (simple-format + (current-error-port) + "exception running resource pool destructor (~A): ~A\n" + name + destructor) + (print-backtrace-and-exception/knots exn) (raise-exception exn)) (lambda () (start-stack #t (destructor resource)) diff --git a/knots/thread-pool.scm b/knots/thread-pool.scm index 3b87be1..f2f174e 100644 --- a/knots/thread-pool.scm +++ b/knots/thread-pool.scm @@ -178,19 +178,18 @@ arguments of the thread pool procedure." (define (initializer/safe) (let ((args (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception running initializer in thread pool (~A): ~A:\n ~A\n" - name - thread-initializer - exn) - #f) + (lambda _ #f) (lambda () - (with-throw-handler #t - thread-initializer - (lambda args - (backtrace)))) + (with-exception-handler + (lambda (exn) + (simple-format + (current-error-port) + "exception running initializer in thread pool (~A): ~A\n" + name + thread-initializer) + (print-backtrace-and-exception/knots exn) + (raise-exception exn)) + thread-initializer)) #:unwind? #t))) (if args @@ -203,21 +202,20 @@ arguments of the thread pool procedure." (define (destructor/safe args) (let ((success? (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception running destructor in thread pool (~A): ~A:\n ~A\n" - name - thread-destructor - exn) - #f) + (lambda _ #f) (lambda () - (with-throw-handler #t + (with-exception-handler + (lambda (exn) + (simple-format + (current-error-port) + "exception running destructor in thread pool (~A): ~A\n" + name + thread-destructor) + (print-backtrace-and-exception/knots exn) + (raise-exception exn)) (lambda () (apply thread-destructor args) - #t) - (lambda _ - (backtrace)))) + #t))) #:unwind? #t))) (or success? @@ -465,20 +463,17 @@ If already in the thread pool, call PROC immediately." (define (thread-process-job job-args) (with-exception-handler - (lambda (exn) - (simple-format (current-error-port) - "~A work queue, job raised exception ~A: ~A\n" - name job-args exn)) + (lambda _ #f) (lambda () - (with-throw-handler #t + (with-exception-handler + (lambda (exn) + (simple-format (current-error-port) + "~A work queue, job raised exception ~A\n" + name job-args) + (print-backtrace-and-exception/knots exn) + (raise-exception exn)) (lambda () - (apply proc job-args)) - (lambda (key . args) - (simple-format - (current-error-port) - "~A work queue, exception when handling job: ~A ~A\n" - name key args) - (backtrace)))) + (apply proc job-args)))) #:unwind? #t)) (define (start-thread thread-index) diff --git a/tests.scm b/tests.scm index 6c07374..2b24c6a 100644 --- a/tests.scm +++ b/tests.scm @@ -12,10 +12,11 @@ (lambda (exn) exn) (lambda () - (with-throw-handler #t - thunk - (lambda _ - (backtrace))) + (with-exception-handler + (lambda (exn) + (backtrace) + (raise-exception exn)) + thunk) #t) #:unwind? #t)) #:hz 0