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