[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/06: Add a JSON error page
From: |
Christopher Baines |
Subject: |
05/06: Add a JSON error page |
Date: |
Fri, 21 Jun 2024 07:30:47 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit 94e66d5b1fe4d8b852bfb403196166db4ccd1f3a
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Jun 21 11:04:57 2024 +0100
Add a JSON error page
---
guix-data-service/web/controller.scm | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/guix-data-service/web/controller.scm
b/guix-data-service/web/controller.scm
index d503052..a20e761 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -718,11 +718,20 @@
startup-controller-thunk)
#:on-error 'backtrace
#:post-error (lambda args
- (render-html #:sxml (error-page
- (if (%show-error-details)
- args
- #f))
- #:code 500))))
+ (case (most-appropriate-mime-type
+ '(application/json text/html)
+ mime-types)
+ ((application/json)
+ (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
startup-completed?)
- branch master updated (d74422c -> 4e7c2bc), Christopher Baines, 2024/06/21
- 01/06: Reduce max-age for the latest-processed-commit page, Christopher Baines, 2024/06/21
- 03/06: Cache the derivations that weren't deleted, Christopher Baines, 2024/06/21
- 02/06: Speed up select-build-outputs, Christopher Baines, 2024/06/21
- 04/06: Speed up deleting derivation sources, Christopher Baines, 2024/06/21
- 06/06: Don't compare across systems in one query, Christopher Baines, 2024/06/21
- 05/06: Add a JSON error page,
Christopher Baines <=