When an ERROR function is invoked, the execution of the current process terminates, the message is immediately displayed, and the database returns to the status it had following the last (implicit or explicit) COMMIT function as though the process calling the ERROR function had not run at all.
An ERROR function call is formatted almost exactly like a MESSAGE call. ERROR has the syntax ERROR (String [, Value1] ,...]), where there are as many ValueX entries as there are %X substitution strings (up to 10). If the preceding MESSAGE was an ERROR function instead, the code line would be follows:
ERROR('Loop %1, Item No. %2',LoopCounter,"Item No.");
The display would look like the following screenshot:
The big X in a bold red circle tells us that this was an ERROR message, but some users might not immediately realize that. We can increase the ease of ERROR message recognition by including the word ERROR in our message, as shown in the following screenshot:
Even in the best of circumstances, it is difficult for a system to communicate clearly with the users. Sometimes our tools, in their effort to be flexible, make it too easy for developers to take the easy way out and communicate poorly or not at all. For example, an ERROR statement of the form ERROR('') will terminate the run, and roll back all data processing without even displaying any message at all. An important part of our job, as developers, is to ensure that our systems communicate clearly and completely.