summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorMathieu OTHACEHE <m.othacehe@gmail.com>2017-01-17 09:17:30 +0100
committerLudovic Courtès <ludo@gnu.org>2017-01-19 17:17:16 +0100
commitd18b79fed895b9ca5cdb3a9a68c8e02bdaef30d8 (patch)
tree28c127e522d6a28a1284ab2537e1bcee6b1fe5cb /guix/import
parent11f3885bb59cbdeec08a929996b4fc39b1746a3e (diff)
import: github: Catch HTTP 403 error during fetch.
* guix/import/github.scm (json-fetch*): Catch 403 HTTP error that may be raised if a github token has not been set. Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com> Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/github.scm9
1 files changed, 6 insertions, 3 deletions
diff --git a/guix/import/github.scm b/guix/import/github.scm
index df5a6b0e08..1e0bb53d9a 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -32,10 +32,13 @@
(define (json-fetch* url)
"Return a representation of the JSON resource URL (a list or hash table), or
-#f if URL returns 404."
+#f if URL returns 403 or 404."
(guard (c ((and (http-get-error? c)
- (= 404 (http-get-error-code c)))
- #f)) ;"expected" if package is unknown
+ (let ((error (http-get-error-code c)))
+ (or (= 403 error)
+ (= 404 error))))
+ #f)) ;; "expected" if there is an authentification error (403),
+ ;; or if package is unknown (404).
;; Note: github.com returns 403 if we omit a 'User-Agent' header.
(let* ((port (http-fetch url))
(result (json->scm port)))