Simplify web server exception handling

This used to be more complicated as the exception handler was
configurable, but now it's not so this can be simplified.
This commit is contained in:
Christopher Baines 2026-03-22 15:16:17 +00:00
parent bb6d9fd89d
commit 677d941cb3

View file

@ -317,26 +317,6 @@ on the procedure being called at any particular time."
;; Close the client port
#f)
(define (exception-handler exn request)
(let* ((error-string
(call-with-output-string
(lambda (port)
(simple-format
port
"exception when processing: ~A ~A\n"
(request-method request)
(uri-path (request-uri request)))
(print-backtrace-and-exception/knots
exn
#:port port)))))
(display/knots error-string
(current-error-port)))
(values (build-response #:code 500)
;; TODO Make this configurable
(string->utf8
"internal server error")))
(define* (handle-request handler client
read-request-exception-handler
write-response-exception-handler
@ -362,18 +342,29 @@ on the procedure being called at any particular time."
(connection . (close))))
#vu8()))
(else
(call-with-escape-continuation
(lambda (return)
(with-exception-handler
(lambda (exn)
(call-with-values
(sanitize-response
request
(build-response #:code 500)
(string->utf8
"internal server error")))
(lambda ()
(exception-handler exn request))
(lambda (response body)
(call-with-values
(lambda ()
(sanitize-response request response body))
return))))
(with-exception-handler
(lambda (exn)
(let* ((error-string
(call-with-output-string
(lambda (port)
(simple-format
port
"exception when processing: ~A ~A\n"
(request-method request)
(uri-path (request-uri request)))
(print-backtrace-and-exception/knots
exn
#:port port)))))
(display/knots error-string
(current-error-port))))
(lambda ()
(start-stack
#t