diff options
author | Christopher Baines <mail@cbaines.net> | 2025-01-26 11:10:19 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2025-01-26 11:10:19 +0000 |
commit | 9f953f3d3d69f5f6efdbcd82cabc9b7bc93e210f (patch) | |
tree | 541296f71dd6ecb0d8a6a50fb889fe7e38bed856 | |
parent | 43ebfc127b9d2d36fae782c783699e821875308b (diff) | |
download | qa-frontpage-9f953f3d3d69f5f6efdbcd82cabc9b7bc93e210f.tar qa-frontpage-9f953f3d3d69f5f6efdbcd82cabc9b7bc93e210f.tar.gz |
Use knots web server exception handling feature
-rw-r--r-- | guix-qa-frontpage/server.scm | 32 | ||||
-rw-r--r-- | guix-qa-frontpage/view/util.scm | 9 |
2 files changed, 19 insertions, 22 deletions
diff --git a/guix-qa-frontpage/server.scm b/guix-qa-frontpage/server.scm index ba17cc3..4beaf09 100644 --- a/guix-qa-frontpage/server.scm +++ b/guix-qa-frontpage/server.scm @@ -830,22 +830,17 @@ Disallow: /issue (request-method request) (uri-path (request-uri request)))) - (call-with-error-handling - (lambda () - (let-values (((request-components mime-types) - (request->path-components-and-mime-type request))) - (call-with-delay-logging - controller - #:threshold 30 - #:args (list request - (cons (request-method request) - request-components) - mime-types - body)))) - #:on-error 'backtrace - #:post-error (lambda args - (render-html #:sxml (error-page args) - #:code 500)))) + (let ((request-components + mime-types + (request->path-components-and-mime-type request))) + (call-with-delay-logging + controller + #:threshold 30 + #:args (list request + (cons (request-method request) + request-components) + mime-types + body)))) (define* (start-guix-qa-frontpage port host assets-directory database metrics-registry @@ -934,6 +929,11 @@ Disallow: /issue (apply values (handler request (read-request-body request) controller))) + #:exception-handler + (lambda (exn) + (apply values + (render-html #:sxml (error-page exn) + #:code 500))) #:host host #:port port) diff --git a/guix-qa-frontpage/view/util.scm b/guix-qa-frontpage/view/util.scm index 575ab3c..497e718 100644 --- a/guix-qa-frontpage/view/util.scm +++ b/guix-qa-frontpage/view/util.scm @@ -432,17 +432,14 @@ main > header { (h1 ,header-text) (p ,body))))) -(define* (error-page #:optional error) +(define* (error-page #:optional exn) (layout #:body `((main (h1 "An error occurred") (p "Sorry about that!") - ,@(if error - (match error - ((key . args) - `((b ,key) - (pre ,args)))) + ,@(if exn + `((pre ,exn)) '()))))) (define file-mime-types |