diff --git a/knots/web-server.scm b/knots/web-server.scm index 10845e6..92e8db6 100644 --- a/knots/web-server.scm +++ b/knots/web-server.scm @@ -345,36 +345,58 @@ on the procedure being called at any particular time." (lambda (return) (with-exception-handler (lambda (exn) - (call-with-values - (lambda () - (exception-handler exn request)) - (match-lambda* - ((response body) - (call-with-values - (lambda () - (sanitize-response request response body)) - return)) - (other - (call-with-values - (lambda () - (default-exception-handler - (make-exception-with-irritants - (list (make-exception-with-message - (simple-format - #f - "wrong number of values returned from exception handler, expecting 2, got ~A" - (length other))) - exception-handler)) - request)) - (match-lambda* - ((response body) - (call-with-values - (lambda () - (sanitize-response - request - response - body)) - return)))))))) + (with-exception-handler + (lambda (exn) + (call-with-values + (lambda () + (default-exception-handler + (make-exception + exn + (make-exception-with-message + "exception in exception handler") + (make-exception-with-irritants + exception-handler)) + request)) + (match-lambda* + ((response body) + (call-with-values + (lambda () + (sanitize-response + request + response + body)) + return))))) + (lambda () + (call-with-values + (lambda () + (exception-handler exn request)) + (match-lambda* + ((response body) + (call-with-values + (lambda () + (sanitize-response request response body)) + return)) + (other + (call-with-values + (lambda () + (default-exception-handler + (make-exception-with-irritants + (list (make-exception-with-message + (simple-format + #f + "wrong number of values returned from exception handler, expecting 2, got ~A" + (length other))) + exception-handler)) + request)) + (match-lambda* + ((response body) + (call-with-values + (lambda () + (sanitize-response + request + response + body)) + return)))))))))) (lambda () (start-stack #t