aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-04-27 19:04:42 +0100
committerChristopher Baines <mail@cbaines.net>2020-04-27 19:04:42 +0100
commit2da92769d3af838bdc5899d3f039e7f441a2ef09 (patch)
treed46df01fb0a8e52989b530cd0fa6517030d8e602
parent5594d6ad65e53724f75122c27379e89b50dc3c9f (diff)
downloadbuild-coordinator-2da92769d3af838bdc5899d3f039e7f441a2ef09.tar
build-coordinator-2da92769d3af838bdc5899d3f039e7f441a2ef09.tar.gz
Add more error handling to coordinator-http-request
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm26
1 files changed, 17 insertions, 9 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index a3a56b5..1fd2516 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -353,15 +353,23 @@ port. Also, the port used can be changed by passing the --port option.\n"
`((Authorization . ,auth-value)
,@headers))))
(if (>= (response-code response) 400)
- (error (catch #t
- (lambda ()
- (json-string->scm (utf8->string body)))
- (lambda (key . args)
- (simple-format
- (current-error-port)
- "error decoding body ~A ~A\n"
- key args)
- #f)))
+ (begin
+ (simple-format
+ (current-error-port)
+ "error: coordinator-http-request: ~A ~A: ~A\n"
+ method path (response-code response))
+ (error (catch #t
+ (lambda ()
+ (if (eq? '(application/json (charset . "utf-8"))
+ (response-content-type response))
+ (json-string->scm (utf8->string body))
+ (utf8->string body)))
+ (lambda (key . args)
+ (simple-format
+ (current-error-port)
+ "error decoding body ~A ~A\n"
+ key args)
+ #f))))
(values
(json-string->scm (utf8->string body))
response))))