Better error messages.

This commit is contained in:
Alex Shinn 2014-07-08 22:39:56 +09:00
parent 3031b50406
commit 78f31ede20

View file

@ -127,7 +127,7 @@
(lambda (x) (lambda (x)
(port->bytevector (port->bytevector
(open-binary-input-file (cdr x))))) (open-binary-input-file (cdr x)))))
(else (error ""))) (else (error "unknown content: " x)))
(cdr x))) (cdr x)))
(content-type (content-type
(cond ((and (pair? (cdr x)) (cond ((and (pair? (cdr x))
@ -157,7 +157,7 @@
(define (http-call-method method url in-headers body limit) (define (http-call-method method url in-headers body limit)
(if (<= limit 0) (if (<= limit 0)
(error "http-get: redirect limit reached" url) (error "http-get: redirect limit reached" (uri->string url))
(let* ((uri (if (uri? url) url (string->uri url))) (let* ((uri (if (uri? url) url (string->uri url)))
(host (and uri (uri-host uri)))) (host (and uri (uri-host uri))))
(if (not host) (if (not host)
@ -203,11 +203,11 @@
(let ((url2 (assq-ref headers 'location))) (let ((url2 (assq-ref headers 'location)))
(if url2 (if url2
(http-get/raw url2 in-headers (- limit 1)) (http-get/raw url2 in-headers (- limit 1))
(error "redirect with no location header")))) (error "redirect with no location header" url url2))))
(else (else
(close-input-port in) (close-input-port in)
(close-output-port out) (close-output-port out)
(error "couldn't retrieve url" url resp))))))))) (error "couldn't retrieve url" (uri->string url) resp)))))))))
(define (http-get/raw url headers limit) (define (http-get/raw url headers limit)
(http-call-method 'GET url headers #f limit)) (http-call-method 'GET url headers #f limit))