diff options
author | Christopher Baines <mail@cbaines.net> | 2021-01-19 18:04:46 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-01-19 18:04:46 +0000 |
commit | 9e696733ac638acbb3c47197b2484cb6ecbc76a0 (patch) | |
tree | d96ceffc279eb1959e36f5c113ab6cd4be3d3fad | |
parent | bd73f8c42963dc7c9a1c769179443849129ada1e (diff) | |
download | build-coordinator-9e696733ac638acbb3c47197b2484cb6ecbc76a0.tar build-coordinator-9e696733ac638acbb3c47197b2484cb6ecbc76a0.tar.gz |
Rework client error handling
To see if that produces better logging.
-rw-r--r-- | guix-build-coordinator/client-communication.scm | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm index 16fa529..580773b 100644 --- a/guix-build-coordinator/client-communication.scm +++ b/guix-build-coordinator/client-communication.scm @@ -378,19 +378,30 @@ "not-found" #:code 404)))) - (call-with-error-handling - controller-thunk - #:on-error 'backtrace - #:post-error (lambda args - (match method-and-path-components - ((method path-components ...) - (simple-format - (current-error-port) - "error: when processing: /~A ~A\n" - method (string-join path-components "/")))) - (render-json - `((error . ,(simple-format #f "~A" args))) - #:code 500)))) + (with-exception-handler + (lambda (exn) + (match method-and-path-components + ((method path-components ...) + (simple-format + (current-error-port) + "error: when processing client request: /~A ~A\n ~A" + method (string-join path-components "/") + exn))) + (render-json + `((error . ,(simple-format #f "~A" exn))) + #:code 500)) + (lambda () + (with-exception-handler + (lambda (exn) + (catch #t + (lambda () + (backtrace)) + (lambda (key . args) + (simple-format (current-error-port) + "error: guile crashed printing backtrace\n"))) + (raise-exception exn)) + controller-thunk)) + #:unwind? #t)) (define* (render-json json #:key (extra-headers '()) (code 200)) |