diff options
author | Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> | 2016-12-17 15:24:45 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2016-12-17 19:13:42 +0100 |
commit | fdbc84b056683204c5832d3740d9b109f31f7cb9 (patch) | |
tree | 44dad5cf38784f3322d50dbb09c89b26bbd04a6f | |
parent | d68ba5f483a42ea324ff31746fde7dcc41600463 (diff) |
import cran: Handle HTTP errors.
Fixes <http://bugs.gnu.org/23479>.
* guix/import/cran.scm (fetch-description): Return #f in case of HTTP
errors.
-rw-r--r-- | guix/import/cran.scm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 123abfe7ea..463a25514e 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -23,8 +23,10 @@ #:use-module ((ice-9 rdelim) #:select (read-string)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (srfi srfi-41) #:use-module (ice-9 receive) + #:use-module (web uri) #:use-module (guix combinators) #:use-module (guix http-client) #:use-module (guix hash) @@ -128,10 +130,18 @@ package definition." (define (fetch-description base-url name) "Return an alist of the contents of the DESCRIPTION file for the R package -NAME, or #f on failure. NAME is case-sensitive." +NAME, or #f in case of failure. NAME is case-sensitive." ;; This API always returns the latest release of the module. (let ((url (string-append base-url name "/DESCRIPTION"))) - (description->alist (read-string (http-fetch url))))) + (guard (c ((http-get-error? c) + (format (current-error-port) + "error: failed to retrieve package information \ +from ~s: ~a (~s)~%" + (uri->string (http-get-error-uri c)) + (http-get-error-code c) + (http-get-error-reason c)) + #f)) + (description->alist (read-string (http-fetch url)))))) (define (listify meta field) "Look up FIELD in the alist META. If FIELD contains a comma-separated |