vl-catch-all-apply

AutoCad AutoLISP Functions

 
vl-catch-all-apply
 
 
 

Passes a list of arguments to a specified function and traps any exceptions

(vl-catch-all-apply 'function list)

Arguments

'function

A function. The function argument can be either a symbol identifying a defun, or a lambda expression.

list

A list containing arguments to be passed to the function.

Return Values

The result of the function call, if successful. If an error occurs, vl-catch-all-apply returns an error object.

Examples

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"
See Also