Show details about page-proxy http errors

This commit is contained in:
Cadence Ember 2022-09-01 16:04:48 +12:00
parent e0e53cc07b
commit 3f1aeb8414
Signed by untrusted user: cadence
GPG key ID: BC1C2C61CF521B17
2 changed files with 11 additions and 9 deletions

View file

@ -8,7 +8,8 @@
net/url net/url
web-server/http web-server/http
(only-in web-server/dispatchers/dispatch next-dispatcher) (only-in web-server/dispatchers/dispatch next-dispatcher)
"url-utils.rkt") "url-utils.rkt"
"xexpr-utils.rkt")
(provide (provide
page-proxy) page-proxy)
@ -17,11 +18,12 @@
(match (dict-ref (url-query (request-uri req)) 'dest #f) (match (dict-ref (url-query (request-uri req)) 'dest #f)
[(? string? dest) [(? string? dest)
(if (is-fandom-url? dest) (if (is-fandom-url? dest)
(let ([dest-r (easy:get dest #:stream? #t)]) (response-handler
(response/output (let ([dest-r (easy:get dest #:stream? #t)])
#:code (easy:response-status-code dest-r) (response/output
#:mime-type (easy:response-headers-ref dest-r 'content-type) #:code (easy:response-status-code dest-r)
(λ (out) #:mime-type (easy:response-headers-ref dest-r 'content-type)
(copy-port (easy:response-output dest-r) out)))) (λ (out)
(copy-port (easy:response-output dest-r) out)))))
(next-dispatcher))] (next-dispatcher))]
[#f (next-dispatcher)])) [#f (next-dispatcher)]))

View file

@ -190,8 +190,8 @@
#:code 500 #:code 500
#:mime-type #"text/plain" #:mime-type #"text/plain"
(λ (out) (λ (out)
(for ([port (list (current-output-port) out)]) (for ([port (list (current-error-port) out)])
(parameterize ([current-error-port out]) (parameterize ([current-error-port port])
(displayln "Exception raised in Racket code at response generation time:" (current-error-port)) (displayln "Exception raised in Racket code at response generation time:" (current-error-port))
((error-display-handler) (exn-message e) e))))))]) ((error-display-handler) (exn-message e) e))))))])
body ...)) body ...))