Use the ReportError method to issue an error message. If the ENVI user interface is displayed, an error dialog appears with a custom message. Also, if the Enable System Logging preference is set to True, the error message will be written to the system log file.

Although the ReportError method can be used in batch programs, it is meant to be used in writing Toolbox extensions. See Manage Errors for more information.

Example


See Write and Deploy Toolbox Extensions for example code that uses the ReportError method.

The following is a simple example that checks for a valid input file.

; Start the application
e = ENVI()
raster = e.OpenRaster(doesnotexist, ERROR=error)
if ERROR then e.ReportError, 'Please provide a valid file', /INFORMATION

If you were to set the HEADLESS keyword to ENVI in the above example, the error message would be written to the system log file (if the Enable System Logging preference were set to True).

Syntax


ENVI.ReportError, Message [, Keywords=value]

Arguments


Message

Specify a string with the error message to be displayed. An error dialog is the default dialog type when you do not set the INFORMATION or WARNING keywords. Here is an example:

Keywords


Keywords are applied only during the initial creation of the object.

ERROR

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

INFORMATION

Set this keyword to display a message in an information dialog. Here is an example:

WARNING

Set this keyword to display a message in a warning dialog. Here is an example:

Version History


ENVI 5

Introduced

API Version


4.2

See Also


ENVI function, Manage Errors, Write and Deploy Toolbox Extensions