LispWorks Delivery User Guide > 9 Delivery and Internal Systems > 9.4 Error handling in delivered applications > 9.4.1 Making the application handle errors

NextPrevUpTopContentsIndex

9.4.1.1 Handling errors generated by the application

Error conditions that can occur in your application domain can be handled easily enough if you define your own error handling or validation functions to trap them. For instance, you might ordinarily have the following code, which manages an error condition and makes a call to error :

 .....
 (let ((res (call-something)))
   (when res
     (generate-error res))
 .....
(defun generate-error(res)
  (error 'application-error     
         :error-number res))

You can easily define a version of generate-error that does all the work:

(defun generate-error (res)
  (let ((action
         (capi:prompt-with-list
          '(("Abort Operation" . abort)
            ("Retry Operation" . retry)
            ("Ignore Error")
            ("Quit" . stop-application)
            ("Do Something Else" . do-something-else))
          (find-error-string res)
          :print-function 'first
          :value-function 'rest)))
    (case action
      ((abort retry) (invoke-restart action))
      ((nil))
      (t (funcall action)))))

LispWorks Delivery User Guide - 22 Dec 2009

NextPrevUpTopContentsIndex