About Handling Errors in a VLX Application Running in Its Own Namespace (Visual LISP IDE)

VLX applications executing within their own namespace, can either use the default *error* function or define an error handler specifically for the application.

Note: The Visual LISP IDE is available on Windows only.

If you define an error handler for a VLX running in its own namespace, you can call the vl-exit-with-error function to pass control from the VLX error handler to the document namespace's *error* function.

The following example uses vl-exit-with-error to pass a string to the document's *error* function:

(defun *error* (msg)
  ... ; processing in VLX namespace/execution context
(vl-exit-with-error (strcat "My application bombed! " msg)))

A VLX *error* handler can use the vl-exit-with-value function to return a value to the document namespace from which the VLX was invoked.

The following example uses vl-exit-with-value to return the integer value 3 to the program that called the VLX from the document namespace:

(defun *error* (msg)
  ... ; processing in VLX-T namespace/execution context
  (vl-exit-with-value  3))
(vl-doc-export 'foo)
(defun foo (x)
  (bar x)
  (print 3))
(defun bar (x) (list (/ 2 x) x))

Any instructions pending at the time the error occurred are flushed.

If your VLX namespace error handler does not use either vl-exit-with-error or vl-exit-with-value, then control returns to the command prompt after execution of the error handler. You can only call vl-exit-with-error and vl-exit-with-value in the context of a VLX application's error handler; it is an error to invoke these functions in any other situation.