Fix exception handling for the web server exception handler

Don't crash if it returns a response with invalid headers.
This commit is contained in:
Christopher Baines 2025-03-08 18:43:44 +00:00
parent e3bc3c12b0
commit 710972691b

View file

@ -345,36 +345,58 @@ on the procedure being called at any particular time."
(lambda (return) (lambda (return)
(with-exception-handler (with-exception-handler
(lambda (exn) (lambda (exn)
(call-with-values (with-exception-handler
(lambda () (lambda (exn)
(exception-handler exn request)) (call-with-values
(match-lambda* (lambda ()
((response body) (default-exception-handler
(call-with-values (make-exception
(lambda () exn
(sanitize-response request response body)) (make-exception-with-message
return)) "exception in exception handler")
(other (make-exception-with-irritants
(call-with-values exception-handler))
(lambda () request))
(default-exception-handler (match-lambda*
(make-exception-with-irritants ((response body)
(list (make-exception-with-message (call-with-values
(simple-format (lambda ()
#f (sanitize-response
"wrong number of values returned from exception handler, expecting 2, got ~A" request
(length other))) response
exception-handler)) body))
request)) return)))))
(match-lambda* (lambda ()
((response body) (call-with-values
(call-with-values (lambda ()
(lambda () (exception-handler exn request))
(sanitize-response (match-lambda*
request ((response body)
response (call-with-values
body)) (lambda ()
return)))))))) (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 () (lambda ()
(start-stack (start-stack
#t #t