aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/agent-messaging/http.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/agent-messaging/http.scm')
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm39
1 files changed, 29 insertions, 10 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 7d96054..7d61ab4 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -22,6 +22,7 @@
#:use-module (srfi srfi-11)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
+ #:use-module (ice-9 exceptions)
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 binary-ports)
#:use-module (system repl error-handling)
@@ -205,15 +206,29 @@ port. Also, the port used can be changed by passing the --port option.\n"
(let ((agent-id-for-build
(datastore-agent-for-build datastore uuid)))
(if (authenticated? agent-id-for-build request)
- (begin
- (handle-build-result datastore hook-channel
- agent-id-for-build uuid
- (json-string->scm (utf8->string body)))
- ;; Trigger build allocation, as the result of this build could
- ;; change the allocation
- (trigger-build-allocation)
- (render-json
- "message received"))
+ (with-exception-handler
+ (lambda (exn)
+ (simple-format (current-error-port)
+ "exception: ~A\n"
+ exn)
+ (render-json
+ `((error . ,(exception-message exn)))
+ #:code 500)) ; TODO better code
+ (lambda ()
+ (with-exception-handler
+ (lambda (exn)
+ (backtrace)
+ (raise-exception exn))
+ (lambda ()
+ (handle-build-result datastore hook-channel
+ agent-id-for-build uuid
+ (json-string->scm (utf8->string body)))
+ ;; Trigger build allocation, as the result of this build
+ ;; could change the allocation
+ (trigger-build-allocation)
+ (render-json
+ "message received"))))
+ #:unwind? #t)
(render-json
"access denied"
#:code 403))))
@@ -415,7 +430,11 @@ port. Also, the port used can be changed by passing the --port option.\n"
#:body (scm->json-string result)
#:headers
`((Authorization . ,auth-value)))))
- (json-string->scm (utf8->string body))))
+ (let ((message
+ (json-string->scm (utf8->string body))))
+ (if (>= (response-code response) 400)
+ (error message)
+ message))))
(define (report-setup-failure coordinator-uri agent-uuid password
build-id report)