diff --git a/src/page-proxy.rkt b/src/page-proxy.rkt index f494e28..8dbf0f9 100644 --- a/src/page-proxy.rkt +++ b/src/page-proxy.rkt @@ -18,13 +18,16 @@ (match (dict-ref (url-query (request-uri req)) 'dest #f) [(? string? dest) (if (is-fandom-url? dest) - (response-handler + (response-handler ; catches and reports errors (let ([dest-r (easy:get dest #:stream? #t)]) - (response/output - #:code (easy:response-status-code dest-r) - #:mime-type (easy:response-headers-ref dest-r 'content-type) - (λ (out) - (copy-port (easy:response-output dest-r) out) - (easy:response-close! dest-r))))) + (with-handlers ([exn:fail? (λ (e) ; cleans up and re-throws + (easy:response-close! dest-r) + (raise e))]) + (response/output + #:code (easy:response-status-code dest-r) + #:mime-type (easy:response-headers-ref dest-r 'content-type) + (λ (out) + (copy-port (easy:response-output dest-r) out) + (easy:response-close! dest-r)))))) (next-dispatcher))] [#f (next-dispatcher)]))