ERROR
The ERROR instruction displays an error message to the user.
Syntax
ERROR expression [,...]
[ {ATTRIBUTE|ATTRIBUTES} ( display-attribute [,...] ) ]
{ BLACK | BLUE | CYAN | GREEN
| MAGENTA | RED | WHITE | YELLOW
| BOLD | DIM | INVISIBLE | NORMAL
| REVERSE | BLINK | UNDERLINE
| STYLE = "style-name"
}- expression is any expression supported by the language.
- style-name is a presentation style name.
Usage
The ERROR instruction displays an error message to the user in an interactive
program.
The error message will remain visible to the end user until the next user interaction like a move to another field or an action execution.
To cleanup the error message text, use ERROR "" .
In TUI mode, the error text is displayed in the error line of the screen. The text of the
ERROR statement is always displayed independently to the current window. The error
line can be defined by the OPTIONS ERROR
LINE instruction.
In GUI mode, you can use the STYLE attribute to
reference a style
definition. This allows you to display errors or messages in GUI mode with more sophisticated
visual effects as the regular TTY attributes. If you want to apply a style automatically to all
program warnings displayed with the ERROR instruction, you can use the :error pseudo selector in the
style definition.
Example
...
UPDATE tab1 SET col1 = ...
IF sqlca.sqlcode < 0 THEN
ERROR SFMT("Row update failed (err=%1)", sqlca.sqlcode)
ATTRIBUTES(STYLE="important")
...
END IF
...