aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-01-19 18:04:46 +0000
committerChristopher Baines <mail@cbaines.net>2021-01-19 18:04:46 +0000
commit9e696733ac638acbb3c47197b2484cb6ecbc76a0 (patch)
treed96ceffc279eb1959e36f5c113ab6cd4be3d3fad /guix-build-coordinator
parentbd73f8c42963dc7c9a1c769179443849129ada1e (diff)
downloadbuild-coordinator-9e696733ac638acbb3c47197b2484cb6ecbc76a0.tar
build-coordinator-9e696733ac638acbb3c47197b2484cb6ecbc76a0.tar.gz
Rework client error handling
To see if that produces better logging.
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r--guix-build-coordinator/client-communication.scm37
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))