diff options
author | Christopher Baines <mail@cbaines.net> | 2021-12-13 15:01:02 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-12-13 15:01:02 +0000 |
commit | 7a53055b3225612657c7349bd6b158ac004b5774 (patch) | |
tree | bc2d0e4912f510c590f1f58552792ac3c4c28379 /nar-herder/mirror.scm | |
parent | 6bbdb713a23659df3b267e7a07fe2c3922617d53 (diff) | |
download | nar-herder-7a53055b3225612657c7349bd6b158ac004b5774.tar nar-herder-7a53055b3225612657c7349bd6b158ac004b5774.tar.gz |
Improve mirror exception handling
Diffstat (limited to 'nar-herder/mirror.scm')
-rw-r--r-- | nar-herder/mirror.scm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/nar-herder/mirror.scm b/nar-herder/mirror.scm index 44ce320..dff0eab 100644 --- a/nar-herder/mirror.scm +++ b/nar-herder/mirror.scm @@ -20,6 +20,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-43) #:use-module (ice-9 threads) + #:use-module (ice-9 exceptions) #:use-module (rnrs bytevectors) #:use-module (web uri) #:use-module (web client) @@ -38,15 +39,16 @@ (define processed-recent-changes (database-select-recent-changes database latest-recent-change)) + (define uri + (string->uri + (string-append mirror "/recent-changes" + (if latest-recent-change + (string-append "?since=" latest-recent-change) + "")))) + (call-with-values (lambda () - (http-get - (string->uri - (string-append mirror "/recent-changes" - (if latest-recent-change - (string-append "?since=" latest-recent-change) - ""))) - #:decode-body? #f)) + (http-get uri #:decode-body? #f)) (lambda (response body) (if (= (response-code response) 200) (let ((json-body (json-string->scm @@ -72,7 +74,12 @@ (else (error "unimplemented")))))) (assoc-ref json-body "recent_changes"))) - (error "unknown response code"))))) + (raise-exception + (make-exception-with-message + (simple-format #f "unknown response: ~A\n code: ~A response: ~A" + (uri->string uri) + (response-code response) + (utf8->string body)))))))) (call-with-new-thread (lambda () |