Stop using the knots web-server exception handler
As I want to remove this.
This commit is contained in:
parent
c602c6b533
commit
73e1c0318b
1 changed files with 58 additions and 40 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#:use-module (fibers channels)
|
#:use-module (fibers channels)
|
||||||
#:use-module (fibers scheduler)
|
#:use-module (fibers scheduler)
|
||||||
#:use-module (fibers conditions)
|
#:use-module (fibers conditions)
|
||||||
|
#:use-module (knots)
|
||||||
#:use-module (knots web-server)
|
#:use-module (knots web-server)
|
||||||
#:use-module (knots resource-pool)
|
#:use-module (knots resource-pool)
|
||||||
#:use-module ((guix build syscalls)
|
#:use-module ((guix build syscalls)
|
||||||
|
|
@ -242,15 +243,8 @@ port. Also, the port used can be changed by passing the --port option.\n"
|
||||||
(let ((render-metrics (make-render-metrics registry)))
|
(let ((render-metrics (make-render-metrics registry)))
|
||||||
(run-knots-web-server
|
(run-knots-web-server
|
||||||
(lambda (request)
|
(lambda (request)
|
||||||
(metric-increment requests-metric)
|
(with-exception-handler
|
||||||
|
(lambda (exn)
|
||||||
(let ((body (read-request-body request)))
|
|
||||||
(handler request finished? body controller
|
|
||||||
secret-key-base
|
|
||||||
startup-completed
|
|
||||||
render-metrics)))
|
|
||||||
#:exception-handler
|
|
||||||
(lambda (exn request)
|
|
||||||
(when (resource-pool-timeout-error? exn)
|
(when (resource-pool-timeout-error? exn)
|
||||||
(spawn-fiber
|
(spawn-fiber
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
@ -261,9 +255,6 @@ port. Also, the port used can be changed by passing the --port option.\n"
|
||||||
pool
|
pool
|
||||||
stats)))))
|
stats)))))
|
||||||
|
|
||||||
;; Use the error output from the default exception handler
|
|
||||||
(default-exception-handler exn request)
|
|
||||||
|
|
||||||
(let ((path-components
|
(let ((path-components
|
||||||
mime-types
|
mime-types
|
||||||
(request->path-components-and-mime-type request)))
|
(request->path-components-and-mime-type request)))
|
||||||
|
|
@ -285,6 +276,33 @@ port. Also, the port used can be changed by passing the --port option.\n"
|
||||||
exn
|
exn
|
||||||
#f))
|
#f))
|
||||||
#:code 500))))))
|
#:code 500))))))
|
||||||
|
(lambda ()
|
||||||
|
(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 error-string
|
||||||
|
(current-error-port)))
|
||||||
|
|
||||||
|
(raise-exception exn))
|
||||||
|
(lambda ()
|
||||||
|
(metric-increment requests-metric)
|
||||||
|
|
||||||
|
(let ((body (read-request-body request)))
|
||||||
|
(handler request finished? body controller
|
||||||
|
secret-key-base
|
||||||
|
startup-completed
|
||||||
|
render-metrics)))))
|
||||||
|
#:unwind? #t))
|
||||||
#:connection-buffer-size (expt 2 16)
|
#:connection-buffer-size (expt 2 16)
|
||||||
#:host host
|
#:host host
|
||||||
#:port port)))
|
#:port port)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue