Error Trapping conundrum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys I am trying to add some error trapping to a bunch of lisp routines, I am using the following error trapping routine
(defun error() ;load function
(prompt "\nGlobal Error Trap Loaded") ;inform user
(princ)
);defun
;;;*==========================================================
(defun initerr () ;init error
(setq curlay (getvar "clayer"))
(setq curcol (getvar "cecolor"))
(setq curlin (getvar "celtype"))
(setq curort (getvar "orthomode"))
(setq oldpost (getvar "dimpost"))
(setq curdimtmove (getvar "dimtmove"))
(setq oldos (getvar "osmode")) ;save settings
(setq curpick (getvar "pickbox"))
(setq temperr *error*) ;save *error*
(setq *error* trap) ;reassign *error*
(princ)
);defun
;;;*===========================================================
(defun trap (errmsg) ;define trap
(command nil nil nil)
(if (not (member errmsg '("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg)) ;print message
)
(command "undo" "b") ;undo back
(setvar "clayer" curlay)
(setvar "cecolor" curcol)
(setvar "celtype" curlin)
(setvar "dimtmove" curdimtmove)
(setvar "dimpost" oldpost)
(setvar "osmode" oldos) ;reset settings
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "pickbox" oldpick)
(princ "\nError Resetting Enviroment ") ;inform user
(terpri)
(setq *error* temperr) ;restore *error*
(princ)
);defun
;;;*===========================================================
(defun reset () ;define reset
(setq *error* temperr) ;restore *error*
(setvar "clayer" curlay)
(setvar "cecolor" curcol)
(setvar "celtype" curlin)
(setvar "dimtmove" curdimtmove)
(setvar "dimpost" oldpost)
(setvar "osmode" oldos);reset settings
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "pickbox" curpick)
(princ)
);defun
;;; End of Error Trapping functions
Then I have a bunch of lisp routines below that typically
(defun c:dosomething ()
(initerr)
(do something)
(reset)
)
If I quit out of a routine I get the following error
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
If I follow through the routines there is no error so I am picking I have messed up the error trap somehow. Where have I messed up?