Apply error handling for loading form files
This commit is contained in:
parent
0a93396589
commit
d3746873aa
2 changed files with 16 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
(defsystem "dev.metalisp.survey"
|
||||
:description "Create questionnaires and analyze the results."
|
||||
:version "0.5.6"
|
||||
:version "0.5.7"
|
||||
:author "Marcus Kammer <marcus.kammer@metalisp.dev>"
|
||||
:source-control (:git "git@git.sr.ht:~marcuskammer/dev.metalisp.survey")
|
||||
:licence "MIT"
|
||||
|
|
|
@ -23,17 +23,24 @@
|
|||
(lang "" :type string)
|
||||
(name "" :type string))
|
||||
|
||||
(defun form-path (q)
|
||||
(uiop:merge-pathnames* (format nil "~a/~a.lisp"
|
||||
(questionnaire-lang q)
|
||||
(questionnaire-name q))
|
||||
(ml-survey/fileops:ensure-questionnaires-dir)))
|
||||
|
||||
(defun load-form (q)
|
||||
(declare (type questionnaire q))
|
||||
"Load a Lisp file containing form definitions."
|
||||
(let* ((form-path (uiop:merge-pathnames* (format nil "~a/~a.lisp"
|
||||
(questionnaire-lang q)
|
||||
(questionnaire-name q))
|
||||
(ml-survey/fileops:ensure-questionnaires-dir))))
|
||||
(unless (probe-file form-path)
|
||||
(error "Form file ~A does not exist." form-path))
|
||||
(load form-path))
|
||||
nil)
|
||||
(let ((form-path (form-path q)))
|
||||
(if (probe-file form-path)
|
||||
(handler-case
|
||||
(load form-path)
|
||||
(file-error (e)
|
||||
(warn "File error occurred: ~A" e))
|
||||
(reader-error (e)
|
||||
(warn "Syntax error occurred: ~A" e)))
|
||||
(error "Form file ~A does not exist." form-path))))
|
||||
|
||||
(defmacro with-form (&body body)
|
||||
"Create a standardized HTML form wrapped in a <main> tag with a pre-defined
|
||||
|
|
Loading…
Add table
Reference in a new issue