Call web server exception handlers with the request

So that this can be used when reporting the exception.
This commit is contained in:
Christopher Baines 2025-01-29 16:18:15 +00:00
parent b5cc5fd077
commit c641c19ce4
2 changed files with 7 additions and 5 deletions

View file

@ -158,7 +158,7 @@ on the procedure being called at any particular time."
((0) (memq 'keep-alive (response-connection response)))))
(else #f)))))
(define (default-write-response-exception-handler exn)
(define (default-write-response-exception-handler exn request)
(simple-format
(current-error-port)
"knots web server: exception replying to client: ~A\n" exn)
@ -166,7 +166,7 @@ on the procedure being called at any particular time."
;; Close the client port
#f)
(define (default-exception-handler exn)
(define (default-exception-handler exn request)
(values (build-response #:code 500)
;; TODO Make this configurable
(string->utf8
@ -193,7 +193,8 @@ on the procedure being called at any particular time."
#vu8()))
(else
(with-exception-handler
exception-handler
(lambda (exn)
(exception-handler exn request))
(lambda ()
(call-with-values (lambda ()
(with-stack-and-prompt
@ -233,7 +234,8 @@ on the procedure being called at any particular time."
(raise-exception exception))))))
#:unwind? #t)))))
(with-exception-handler
write-response-exception-handler
(lambda (exn)
(write-response-exception-handler exn request))
(lambda ()
(write-response response client)

View file

@ -44,7 +44,7 @@
(values '((content-type . (text/plain)))
"Hello, World!"))
#:write-response-exception-handler
(lambda (exn)
(lambda (exn request)
(spawn-fiber
(lambda ()
(put-message exception-handled-sucecssfully-channel