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)
(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