Start trying to improve exceptions and backtraces

When using knots utilities.
This commit is contained in:
Christopher Baines 2025-02-03 15:44:51 +00:00
parent bddc6c04ad
commit 893299ba24
3 changed files with 125 additions and 40 deletions

View file

@ -35,6 +35,7 @@
#:use-module (web http)
#:use-module (web request)
#:use-module (web response)
#:use-module (knots)
#:use-module (knots timeout)
#:use-module (knots non-blocking)
#:export (run-knots-web-server
@ -203,8 +204,7 @@ on the procedure being called at any particular time."
#f)
(define (default-exception-handler exn request)
(let* ((stack (make-stack #t))
(error-string
(let* ((error-string
(call-with-output-string
(lambda (port)
(simple-format
@ -212,12 +212,9 @@ on the procedure being called at any particular time."
"exception when processing: ~A ~A\n"
(request-method request)
(uri-path (request-uri request)))
(display-backtrace stack port 4)
(print-exception
port
(stack-ref stack 4)
'%exception
(list exn))))))
(print-backtrace-and-exception/knots
exn
#:port port)))))
(display error-string
(current-error-port)))