Author Topic: Error handling with multiple defuns in same lisp  (Read 1715 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Error handling with multiple defuns in same lisp
« on: October 26, 2018, 02:02:25 PM »
What is the proper method for error handling multiple lisp routines in one file?

so....
Defun routine1 (/)
 error handler
 do stuff

end error
end defun

------------------------
Defun routine2 (/)
 error handler
do stuff

end error
end defun

(routine1)
(routine2)

OR

Error handling
Defun routine1 (/)
  do stuff
end defun

-------------------------
Defun routine2 (/)
 do stuff
end defun
end error

J. Logan
ACAD 2018
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Augusto

  • Newt
  • Posts: 74
« Last Edit: October 26, 2018, 04:35:54 PM by Augusto »

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Error handling with multiple defuns in same lisp
« Reply #2 on: October 26, 2018, 04:35:52 PM »
Error handling is preferably used to trace error while routine (defun) is processing and when it catches error it should act appropriate to avoid unexpected results of evaluation of error... So if you set handling outside of routine definition, errors of definition executions can only be caught through that handler if error definition overwrites default CAD error global handling and traced errors can trigger reactions that are evaluated on global level forcing prompting of error that is hard to trace within local defuns inside scope of handler... In your first example execution is logically structured - processing definitions have local handling and therefore errors inside that scope of definition can be correctly traced and error caught in the place where error occur pointing programmer to syntax which caused routine failure so that appropriate action can be taken to avoid incorrect processing of routine in its entirety... Though this also leaves space to incorporate appropriate error definition of handler to ensure that when error is caught routine steps into section where post processing is treated by error handler definition instead of normal path starting of execution and processing all up to the end of routine definition... So if I am to vote between 2 examples I would be supporter of first example, though you probably have to define handling twice for both definitions, but then you could be sure you can see both separate processing results separately and then if you need combining result, you can make separate main defun calling both integrated definitions and pass results to process final gather result for which you can have and probably it would be sufficient main error handler for main gathering definition.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

jlogan02

  • Bull Frog
  • Posts: 327
Re: Error handling with multiple defuns in same lisp
« Reply #3 on: November 01, 2018, 05:01:56 PM »
Thanks for the links and explanations. Huge help.

J. Logan
ACAD 2018
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10