Call web server exception handlers with the request
So that this can be used when reporting the exception.
This commit is contained in:
parent
b5cc5fd077
commit
c641c19ce4
2 changed files with 7 additions and 5 deletions
|
@ -158,7 +158,7 @@ on the procedure being called at any particular time."
|
||||||
((0) (memq 'keep-alive (response-connection response)))))
|
((0) (memq 'keep-alive (response-connection response)))))
|
||||||
(else #f)))))
|
(else #f)))))
|
||||||
|
|
||||||
(define (default-write-response-exception-handler exn)
|
(define (default-write-response-exception-handler exn request)
|
||||||
(simple-format
|
(simple-format
|
||||||
(current-error-port)
|
(current-error-port)
|
||||||
"knots web server: exception replying to client: ~A\n" exn)
|
"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
|
;; Close the client port
|
||||||
#f)
|
#f)
|
||||||
|
|
||||||
(define (default-exception-handler exn)
|
(define (default-exception-handler exn request)
|
||||||
(values (build-response #:code 500)
|
(values (build-response #:code 500)
|
||||||
;; TODO Make this configurable
|
;; TODO Make this configurable
|
||||||
(string->utf8
|
(string->utf8
|
||||||
|
@ -193,7 +193,8 @@ on the procedure being called at any particular time."
|
||||||
#vu8()))
|
#vu8()))
|
||||||
(else
|
(else
|
||||||
(with-exception-handler
|
(with-exception-handler
|
||||||
exception-handler
|
(lambda (exn)
|
||||||
|
(exception-handler exn request))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(call-with-values (lambda ()
|
(call-with-values (lambda ()
|
||||||
(with-stack-and-prompt
|
(with-stack-and-prompt
|
||||||
|
@ -233,7 +234,8 @@ on the procedure being called at any particular time."
|
||||||
(raise-exception exception))))))
|
(raise-exception exception))))))
|
||||||
#:unwind? #t)))))
|
#:unwind? #t)))))
|
||||||
(with-exception-handler
|
(with-exception-handler
|
||||||
write-response-exception-handler
|
(lambda (exn)
|
||||||
|
(write-response-exception-handler exn request))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(write-response response client)
|
(write-response response client)
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
(values '((content-type . (text/plain)))
|
(values '((content-type . (text/plain)))
|
||||||
"Hello, World!"))
|
"Hello, World!"))
|
||||||
#:write-response-exception-handler
|
#:write-response-exception-handler
|
||||||
(lambda (exn)
|
(lambda (exn request)
|
||||||
(spawn-fiber
|
(spawn-fiber
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(put-message exception-handled-sucecssfully-channel
|
(put-message exception-handled-sucecssfully-channel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue