vl-catch-all-apply (AutoLISP)

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

Supported Platforms: Windows and Mac OS

Signature

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

Type: Symbol

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

list

Type: List

A list containing arguments to be passed to the function.

Return Values

Type: Integer, Real, String, List, ads_name, T, nil, or catch-all-apply-error

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"