company logo

Error Handling

OSI supports error handling, which simplifies the process flow, but also provides ways of writing messages to the error log file. Error handling includes setting (firing) errors and handling errors.

Errors can be handled in an error block. Errors, which are not handled act like LEAVE after writing the error to the message file.

Generating an error in an OSI method

Errors are generated in an OSI method using the ERROR() function. You may call error without parameters, with a string or with a number. The parameter passed contains information to written to the error log file.

A text might be passed as string (or char) to the ERROR function, which is written as default error 999 to the error log file. Generating an error

error("message text")

will lead to the following error message:

Error in expression 'class_name::expr_name" line nnn: message text

Passing the message directly as text does not allow defining multilingual messages. You may define a multilingual message in the resource database (dictionary), which is identified by message number. In this case, you may pass the message number to the error function:

error(47)

Now, the message is displayed according to the message characteristics defined in the message, i.e. as information, warning error or decision. The error text in the message may refer to message variables (using %n). The following message variables are provided by the system:

%1 - class name or "undefined"

%2 - expression name (or "__inline_expression__" for ad-hoc expressions

%3 - current line number

You may pass additional error information by passing up to three text fields to the error function:

error(47,f1,f2,f3);

which can be referenced by message variables %4, %5 and %6 in the error message.

Regardless on the parameters passed to the error function the method continues processing with the ON_ERROR section. When no ON_ERROR section has been defined in the method, the method continues with the FINAL block. When no final block is defined, the function terminates returning the value of the last statement executed before the error function.

Handling errors in OSI methods

Errors in OSI methods can be handled in the ON_ERROR section. The error section is executed, only, when an error has been set in the OSI method (ERROR()).

Within the error method you may display further information or perform any other action except calling the ERROR() function again. Typically, the return value is set in the error case. In contrast to exceptions, in case of an error the method is responsible for setting the proper return value.

The error block is also called in case of exceptions. How to handle exception in the error block is described in "exception Handling".

{

process

on_error

  Message("...");    Display a message box to the user

  return(false);

final

}

Related topics