The vl-catch-all-apply function allows you to intercept errors returned by ActiveX methods, and decide how the program should continue.
 New File. 
		  
 Save As. 
		  (defun init-motivate ()
  (vl-load-com)
  (setq mspace
    (vla-get-modelspace
      (vla-get-activedocument (vlax-get-acad-object))
    )
  )
  (vla-addray mspace (vlax-3d-point 0 0 0) (vlax-3d-point 1 1 0))
)
 
		  (defun bnddrop (/ bbox)
  (setq bbox (vla-getboundingbox
    (vla-item mspace (- 1 (vla-get-count mspace)))
      'll
      'ur
    )
  )
  (list "Do something with bounding box." bbox)
)
 
		  
 Load Text in Editor. 
		  Because a Ray object extends to infinity, it is not possible to enclose it with a box, and GetBoundingBox results in the following error:
; error: Automation Error. Invalid extents
If this code were part of your application program, execution would halt at this point.
(defun bndcatch (/ bbox)
  (setq bbox (vl-catch-all-apply
    'vla-getboundingbox
      (list (vla-item mspace (- 1 (vla-get-count mspace)))
        'll
        'ur
      )
    )
  )
  (if (vl-catch-all-error-p bbox)
    (list "Exception: " (vl-catch-all-error-message bbox))
    (list "Do something with bounding box." bbox)
  )
)
 
			 This function uses vl-catch-all-apply to call vla-getboundingbox. It passes vl-catch-all-apply two arguments: the symbol naming the function being called ('vla-getboundingbox) and a list of arguments to be passed to vla-getboundingbox. If the GetBoundingBox method completes successfully, vl-catch-all-apply stores the return value in variable bbox. If the call is unsuccessful, vl-catch-all-apply stores an error object in bbox.
At this point in the bnddrop function, vla-getboundingbox was issued directly, an error resulted, and execution halted. But in bndcatch, vl-catch-all-apply intercepts the error and program execution continues.
A call to vl-catch-all-error-p checks the return value from vl-catch-all-apply and returns T if it is an error object, nil otherwise. If the return value is an error object, as it would be in this example, the function issues vl-catch-all-error-message to obtain the message from the error object. Program execution continues from this point.