Add a JSON error page

This commit is contained in:
Christopher Baines 2024-06-21 11:04:57 +01:00
parent 84a2ad5b25
commit 94e66d5b1f

View file

@ -718,11 +718,20 @@
startup-controller-thunk) startup-controller-thunk)
#:on-error 'backtrace #:on-error 'backtrace
#:post-error (lambda args #:post-error (lambda args
(render-html #:sxml (error-page (case (most-appropriate-mime-type
(if (%show-error-details) '(application/json text/html)
args mime-types)
#f)) ((application/json)
#:code 500)))) (render-json `((error . ,(if (%show-error-details)
(simple-format #f "~A" args)
#f)))
#:code 500))
(else
(render-html #:sxml (error-page
(if (%show-error-details)
args
#f))
#:code 500))))))
(define* (base-controller request method-and-path-components (define* (base-controller request method-and-path-components
startup-completed?) startup-completed?)