Passes a list of arguments to a specified function and traps any exceptions
(vl-catch-all-apply 'function list)
The result of the function call, if successful. If an error occurs, vl-catch-all-apply returns an error object.
If the function invoked by vl-catch-all-apply completes successfully, it is the same as using apply, as the following examples show:
_$ (setq catchit (apply '/ '(50 5)))
10
_$ (setq catchit (vl-catch-all-apply '/ '(50 5)))
10
The benefit of using vl-catch-all-apply is that it allows you to intercept errors and continue processing. See what happens when you try to divide by zero using apply:
_$ (setq catchit (apply '/ '(50 0)))
; error: divide by zero
When you use apply, an exception occurs and an error message displays.
Here is the same operation using vl-catch-all-apply:
_$ (setq catchit (vl-catch-all-apply '/ '(50 0)))
#<%catch-all-apply-error%>
The vl-catch-all-apply function traps the error and returns an error object. Use vl-catch-all-error-message to see the error message contained in the error object:
_$ (vl-catch-all-error-message catchit)
"divide by zero"
-
The *error*, vl-catch-all-error-p, and vl-catch-all-error-message functions. The
Error Handling in AutoLISP topic in the AutoLISP Developer's Guide.