From 2c75c571e0522dc067bcc536769539f0e9e22534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 17 Mar 2022 22:14:54 +0100 Subject: Use catch* where appropriate --- module/calp/html/vcomponent.scm | 13 +++++++++---- module/calp/server/routes.scm | 43 ++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index 9f7a30ba..c832ea93 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -39,10 +39,15 @@ ;; NOTE this should have information about context (html/term/...) ;; And then be moved somewhere else. (define-public (format-description ev str) - (catch #t (lambda () ((get-config 'description-filter) ev str)) - (lambda (err . args) - (warning "~a on formatting description, ~s" err args) - str))) + (catch* (lambda () ((get-config 'description-filter) ev str)) + (configuration-error + (lambda (key subr msg args data) + (format (current-error-port) + "Error retrieving configuration, ~?~%" msg args))) + (#t ; for errors when running the filter + (lambda (err . args) + (warning "~a on formatting description, ~s" err args) + str)))) ;; used by search view (define-public (compact-event-list list) diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm index ee1f3cb2..7a5dd058 100644 --- a/module/calp/server/routes.scm +++ b/module/calp/server/routes.scm @@ -413,28 +413,27 @@ (define error #f) (define search-result - (catch #t - (lambda () - (catch 'max-page - ;; TODO Get-page only puts a time limiter per page, meaning that - ;; if a user requests page 1000 the server is stuck trying to - ;; find that page, which can take up to 1000 * timeslice = 500s = 8min+ - ;; A timeout here, and also an actual multithreaded server should - ;; solve this. - (lambda () (get-page paginator page)) - (lambda (err page-number) - (define location - (build-relative-ref - path: r:path ; host: r:host port: r:port - query: (encode-query-parameters - `((p . ,page-number) - (q . ,search-term))))) - (return (build-response - code: 307 - headers: `((location . ,location))))))) - (lambda (err callee fmt arg data) - (set! error - (format #f "~?~%" fmt arg))))) + ;; TODO Get-page only puts a time limiter per page, meaning that + ;; if a user requests page 1000 the server is stuck trying to + ;; find that page, which can take up to 1000 * timeslice = 500s = 8min+ + ;; A timeout here, and also an actual multithreaded server should + ;; solve this. + (catch* (lambda () (get-page paginator page)) + (max-page + (lambda (err page-number) + (define location + (build-relative-ref + path: r:path ; host: r:host port: r:port + query: (encode-query-parameters + `((p . ,page-number) + (q . ,search-term))))) + (return (build-response + code: 307 + headers: `((location . ,location)))))) + (#t + (lambda (err callee fmt arg data) + (set! error + (format #f "~?~%" fmt arg)))))) (return '((content-type application/xhtml+xml)) (with-output-to-string -- cgit v1.2.3