[Bese-devel] UCW guidance
Vladimir Sekissov
svg at surnet.ru
Tue Sep 6 07:51:51 UTC 2005
Good day,
jan> I've encountered the next snag: how do I error-check a form and feed it
jan> back to the user if it contains errors?
jan>
jan> An example to that effect would be very, very helpful -- I couldn't find
jan> one in the examples.
I'd posted code for `status-bar-mixin' to mailing list which I
use for such purposes:
http://common-lisp.net/pipermail/bese-devel/2005-June/000396.html
I use it in form as:
(defun collect-error (condition)
(flet ((error-collector (error-tag error)
(show-message (format nil "~a" error) :severity error-tag)))
(let ((restart (find-restart 'collect-error)))
(when restart (invoke-restart restart
#'error-collector
condition)))))
(defmacro with-collect-error (body-form on-error-form &key (error-tag :error))
(let ((error-collector (gensym))
(condition (gensym)))
`(restart-case ,body-form
(collect-error (,error-collector ,condition)
(funcall ,error-collector ,error-tag ,condition)
,on-error-form))))
....
(handler-bind ((error #'collect-error))
(dolist (field (form-fields form))
(with-collect-error
(validate-form-field field)
nil)))
Best Regards,
Vladimir Sekissov
More information about the bese-devel
mailing list