Error handling
- Last Updated: June 8, 2021
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
When an ABL SAX application parses an XML document, it could encounter one of three distinct parse-related error situations. They are:
-
The SAX-PARSE( ),SAX-PARSE-FIRST( ), orSAX-PARSE-NEXT( )detects an error and cannot complete its current parse operation.This might be caused by one of the following:
- The specified XML source does not exist.
- The handle to the procedure or method containing the callbacks is invalid.
SAX-readerwas not in the appropriate state. For example, this can happen ifSAX-PARSE-NEXT( )was called beforeSAX-PARSE-FIRST( ).
If this error condition occurs, parsing stops and the AVM raises an error.
If
NO-ERRORwas specified, the AVM setsERROR-STATUS:ERRORtoYES, setsERROR-STATUS:NUM-MESSAGESto the number of errors encountered, and returns OpenEdge error messages in response to a statement with the following syntax:ERROR-STATUS:GET-MESSAGE(err-msg-num).Where err-msg-num indicates a number between 1 and
ERROR-STATUS:NUM-MESSAGESinclusive.You can also handle the error by way of a
CATCHblock if the method call does not contain theNO-ERRORoption.If the error is not trapped by a
NO-ERRORoption or aCATCHblock, or handled by an explicitON ERRORphrase orUNDOstatement, then the AVM executes the default error handling behavior for the block type containing the method call. For more information, see ABL Error Handling. - A callback raises an error by using the
RETURNstatementERRORoption.If this error situation occurs, parsing stops, the AVM raises an error, and the
RETURN-VALUEis set to whatever string theRETURNstatement included.If
NO-ERRORwas specified, the AVM setsERROR-STATUS:ERRORtoTRUEand setsERROR-STATUS:NUM-MESSAGESto zero.You can also handle the error by way of a
CATCHblock if the method call does not contain theNO-ERRORoption.If
NO-ERRORwas not specified, the AVM looks in the driver routine for the closest block that has the error property and behaves as if the block has an explicitON ERRORphrase. For more information, see OpenEdge Development: ABL Error Handling.
RETURN ERROR or throws a Progress.Lang.AppError, each preceding procedure or method in the chain
must also execute RETURN ERROR or re-throw the Progress.Lang.AppError, otherwise the error condition is
never communicated to the driver routine. This is a standard AVM behavior.- While a callback is executing, the AVM raises an error that the
callback does not handle; for example, a
FIND CUSTOMERthat fails to find the specified customer.If this error occurs:
- The error is displayed (which is standard AVM behavior).
- In the callback, the AVM finds the closest block that has
the error property (which might be the
PROCEDUREblock or CLASS block) and behaves according to the block's explicit or implicitON ERRORphrase. This might cause the AVM to break out of the callback. - The
PARSE-STATUSattribute and theERROR-STATUShandle are unaffected. - The parse continues.