aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-15 02:00:13 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-15 02:25:27 +0100
commit3c6cd75da8c81dd41356164d240c39e55a7c683f (patch)
tree399cbcc532d54ebd0ace0b62fe1a3c76f5c1ffb9
parentAdd JS user config for hyperlinking locations at LiU. (diff)
downloadcalp-3c6cd75da8c81dd41356164d240c39e55a7c683f.tar.gz
calp-3c6cd75da8c81dd41356164d240c39e55a7c683f.tar.xz
HTML directory table now gives 404 instead of 500
-rw-r--r--module/calp/server/routes.scm14
1 files changed, 9 insertions, 5 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm
index 07ea67f0..2e282f91 100644
--- a/module/calp/server/routes.scm
+++ b/module/calp/server/routes.scm
@@ -475,11 +475,15 @@
;; Note that `path' will most likely start with a slash
(GET "/static:path{.*}" (path)
- (return
- '((content-type text/html))
- (sxml->html-string
- ;; TODO 404 instead of 500 here
- (directory-table (static-dir) path))))
+ (catch
+ 'misc-error
+ (lambda () (return
+ '((content-type text/html))
+ (sxml->html-string
+ (directory-table (static-dir) path))))
+ (lambda (err proc fmt fmt-args data)
+ (return (build-response code: 404)
+ (format #f "~?" fmt fmt-args)))))
;; This is almost the same as /static/, but with the difference that
;; we produce these images during runtime