Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Exception conditions and exception statuses

An exception condition can occur at runtime in the form of a deviation from the normal execution of a COBOL statement.
To permit a targeted reaction to an exception condition in a program or method, it is possible, during file processing, not only to specify explicit clauses (e.g. SIZE ERROR phrase) and inquire input and output statuses, but also to trigger exception statuses for some exception conditions and to process these in USE procedures. These exception conditions are assigned exception condition names which enable them to be referenced. A list of these names is provided in table 45.
In order to trigger the associated exception status for an exception condition which has occurred, checking of the condition must be activated using the >>TURN directive.

If the check is activated for an exception condition but a clause (without NOT) which can be used to handle the exception condition is also specified (e.g. INVOKE ... ON EXCEPTION for EC-OO-NULL), the clause has precedence, i.e. the exception condition is checked (because of the clause), but the associated exception status is not triggered.

Furthermore, exception statuses can be triggered directly by the RAISE statement.

If an exception status is triggered, the last exception status is updated. This applies for the entire run unit until a new exception status is triggered or the SET LAST EXCEPTION TO OFF statement is executed. The associated name can be inquired via the EXCEPTION-STATUS function.
The further procedure depends on the severity (category) of the exception condition. Exception conditions are either FATAL or NON-FATAL.

Triggering a FATAL exception condition

  1. If a USE procedure is specified for the exception condition, it is activated.

  2. If the end of the USE procedure is reached without the USE procedure being exited explicitly beforehand, the program run is aborted.

  3. If no USE procedure is specified, the program run is aborted.

Triggering a NON-FATAL exception condition

  1. If a USE procedure is specified for the exception condition, it is activated.

  2. When the end of the USE procedure is reached without being exited explicitly beforehand, program execution is aborted.

  3. If no USE procedure is specified, the program run is continued as if the check of the exception condition is deactivated.

Exception condition names

The table below contains a list of the exception condition names which are supported by the current compiler version.

Meaning of the columns

Name:

Names of the exception conditions.

Cat:

Category of the exception condition: Fatal, Non-Fatal (NF).

Brief description:

Case in which the exception condition occurs

Clauses:

The exception condition can be handled by the specified clauses.

Name

Cat

Brief description

Clauses

EC-DATA-CONVERSION

NF

Replacement character while conversion

-

EC-OO-CONFORMANCE

Fatal

Error in object view

-

EC-OO-METHOD

Fatal

Method not found

ON EXCEPTION

EC-OO-NULL

Fatal

Method called with a NULL object reference

ON EXCEPTION

EC-OO-RESOURCE

Fatal

Not enough storage space available to generate an object

-

EC-OO-UNIVERSAL

Fatal

Conformity rules not met for method call via universal object reference

ON EXCEPTION

EC-STORAGE-NOT-ALLOC

NF

Pointer in the FREE does not point to a storage area allocated by ALLOCATE

-

EC-STORAGE-NOT-AVAIL

NF

The storage specified in an ALLOCATE statement is not available

-

EC-XML-CODESET-CONVERSION

NF

Replacement character while converting an XML document

-

Table 45: Exception condition names