Commits

Peter Bex committed 47795c1

Add better error reporting to make Felix happy :)

Comments (0)

Files changed (1)

henrietta-cache.scm

       (error "Got an error while executing command " cmd))))
 
 (define (pipe-from-http uri cmd)
-  (call-with-input-request
-   uri #f (lambda (i) (call-with-output-pipe*
-                        cmd
-                        (lambda (o) (copy-port i o))))))
+  (condition-case
+      (call-with-input-request
+       uri #f (lambda (i) (call-with-output-pipe*
+                           cmd
+                           (lambda (o) (copy-port i o)))))
+    (e (exn http)
+       (error (sprintf "Could not download ~A -- ~A"
+                       uri (get-condition-property e 'exn 'message))))))
 
 (define (download-release distribution-file-type uri cache-dir)
   (case distribution-file-type
     ((zip)
      (let ((tmpdir (create-temporary-directory))
            (tmp-zipfile (create-temporary-file)))
-       (call-with-input-request
-        uri #f (lambda (i) (call-with-output-file tmp-zipfile
-                             (lambda (o) (copy-port i o)))))
+       (condition-case
+           (call-with-input-request
+            uri #f (lambda (i) (call-with-output-file tmp-zipfile
+                                 (lambda (o) (copy-port i o)))))
+         (e (exn http)
+            (error (sprintf "Could not fetch zip-file ~A -- ~A"
+                            uri (get-condition-property e 'exn 'message)))))
        (let* ((cmd (sprintf "unzip -d ~A -o -qq ~A"
                             (qs tmpdir) (qs tmp-zipfile)))
               (status (system cmd)))
          (rename-file contents-dir cache-dir)
          (system (sprintf "rm -rf ~A" (qs tmpdir))))))
     ((meta-file)
-     (let* ((meta (car (call-with-input-request uri #f read-file)))
-            (uri (uri-reference uri))
-            (add-to-uri
-             (lambda (f)
-               (let* ((components (string-split f "/"))
-                      (rel (update-uri (uri-reference "") path: components)))
-                 (uri-relative-to rel uri))))
-            (files (alist-ref 'files meta)))
-       (unless files
-         (error "No \"files\" entry found in meta file" uri))
-       (for-each
-        (lambda (file)
-          (printf "\t\t~A...\n" file)
-          (flush-output)
-          (and-let* ((dirname (pathname-directory file))
-                     (directory (make-pathname cache-dir dirname)))
-            (unless (file-exists? directory)
-              (create-directory directory #t)))
-          (call-with-input-request
-           (add-to-uri file) #f
-           (lambda (i)
-             (call-with-output-file
-                 (make-pathname cache-dir file)
-               (lambda (o) (copy-port i o))))))
-        files)))
+     (condition-case
+         (let* ((meta (car (call-with-input-request uri #f read-file)))
+                (uri (uri-reference uri))
+                (add-to-uri
+                 (lambda (f)
+                   (let* ((components (string-split f "/"))
+                          (rel (update-uri (uri-reference "") path: components)))
+                     (uri-relative-to rel uri))))
+                (files (alist-ref 'files meta)))
+           (unless files
+             (error "No \"files\" entry found in meta file" uri))
+           (for-each
+            (lambda (file)
+              (printf "\t\t~A...\n" file)
+              (flush-output)
+              (and-let* ((dirname (pathname-directory file))
+                         (directory (make-pathname cache-dir dirname)))
+                (unless (file-exists? directory)
+                  (create-directory directory #t)))
+              (condition-case
+                  (call-with-input-request
+                   (add-to-uri file) #f
+                   (lambda (i)
+                     (call-with-output-file
+                         (make-pathname cache-dir file)
+                       (lambda (o) (copy-port i o)))))
+                (e (exn http)
+                   (error (sprintf
+                           (conc "Could not download file \"~A\", "
+                                 "listed in meta-file (full URI: ~A) -- ~A")
+                           file (uri->string (add-to-uri file))
+                           (get-condition-property e 'exn 'message))))))
+            files))
+       (e (exn http)
+          (error (sprintf "Could not download meta-file \"~A\" -- ~A\n"
+                          uri (get-condition-property e 'exn 'message))))))
     (else (error "Unknown distribution file type" distribution-file-type))))
 
 (define (download-all-release-files egg-name uris/releases uris)
   (handle-exceptions exn
     (begin
       (fprintf (current-error-port)
-               "Could not fetch release-info file for egg ~A from ~A\n"
-               egg-name uri)
+               "Could not fetch release-info file for egg ~A from ~A -- ~A\n"
+               egg-name uri (get-condition-property exn 'exn 'message))
       (flush-output (current-error-port))
       '())
     (with-input-from-request uri #f read-file)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.