aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/agent-messaging
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-24 14:54:45 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-24 14:54:45 +0100
commitd773cf49579af6a96736959e97314ce1218382e7 (patch)
tree19df1a610686a987aef0cb27147bbd4cca7aef73 /guix-build-coordinator/agent-messaging
parent10dee5481f12a6f4a53afaacc27277ba9461ffc4 (diff)
downloadbuild-coordinator-d773cf49579af6a96736959e97314ce1218382e7.tar
build-coordinator-d773cf49579af6a96736959e97314ce1218382e7.tar.gz
Better handle agent errors on the coordinator side
Things like the agent not having the log file, or an output. This will allow the agent to actually retry the relevant thing.
Diffstat (limited to 'guix-build-coordinator/agent-messaging')
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm31
1 files changed, 18 insertions, 13 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm
index c9d70d6..a8e0d46 100644
--- a/guix-build-coordinator/agent-messaging/http/server.scm
+++ b/guix-build-coordinator/agent-messaging/http/server.scm
@@ -457,16 +457,21 @@ port. Also, the port used can be changed by passing the --port option.\n"
"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: /~A ~A\n"
+ method (string-join path-components "/"))))
+ (if (agent-error? exn)
+ (render-json
+ `((error . ,(agent-error-details exn)))
+ #:code 400)
+ (render-json
+ `((error . ,(simple-format #f "~A" exn)))
+ #:code 500)))
+ controller-thunk
+ #:unwind? #t))
+