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

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



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


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.


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)))
_$ (setq catchit (vl-catch-all-apply
'/ '(50 5)))

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)))

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