aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-05-02 16:12:11 +0200
committerChristopher Baines <mail@cbaines.net>2023-05-02 16:12:11 +0200
commitd0f9ad21854ba01039b1f7c964a0d45cc06b3644 (patch)
treeb29719e708ccb6ce51a20fe748daba478a23bef8 /guix-build-coordinator
parent2448b2026bb1f5e0cee6f78b7d3b2e6a30905136 (diff)
downloadbuild-coordinator-d0f9ad21854ba01039b1f7c964a0d45cc06b3644.tar
build-coordinator-d0f9ad21854ba01039b1f7c964a0d45cc06b3644.tar.gz
Return the appropriate HTTP status on client errors
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r--guix-build-coordinator/client-communication.scm30
1 files changed, 19 insertions, 11 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm
index d732f9f..c98d403 100644
--- a/guix-build-coordinator/client-communication.scm
+++ b/guix-build-coordinator/client-communication.scm
@@ -603,21 +603,29 @@
(with-exception-handler
(lambda (exn)
- (render-json
- `((error . 500))
- #:code 500))
+ (cond
+ ((client-error? exn)
+ (render-json
+ `((error . ,(client-error-details exn)))
+ #:code 400))
+ (else
+ (render-json
+ `((error . 500))
+ #:code 500))))
(lambda ()
(with-throw-handler #t
controller-thunk
(lambda (key . args)
- (match method-and-path-components
- ((method path-components ...)
- (simple-format
- (current-error-port)
- "error: when processing client request: /~A ~A\n ~A ~A\n"
- method (string-join path-components "/")
- key args)))
- (backtrace))))
+ (unless (and (eq? '%exception key)
+ (client-error? (car args)))
+ (match method-and-path-components
+ ((method path-components ...)
+ (simple-format
+ (current-error-port)
+ "error: when processing client request: /~A ~A\n ~A ~A\n"
+ method (string-join path-components "/")
+ key args)))
+ (backtrace)))))
#:unwind? #t))
(define* (render-json json #:key (extra-headers '())