Try OpenEdge Now
skip to main content
Working with XML
Reading XML Documents with the Simple API for XML (SAX) : Understanding ABL SAX : Error handling
 

Error handling

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( ), or SAX-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 containing the callbacks is invalid.
*SAX-reader was not in the appropriate state. For example, this can happen if SAX-PARSE-NEXT( ) was called before SAX-PARSE-FIRST( ).
If this error condition occurs, parsing stops and the AVM raises an error.
If NO-ERROR was specified, the AVM sets ERROR-STATUS:ERROR to YES, sets ERROR-STATUS:NUM-MESSAGES to 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-MESSAGES inclusive.
You can also handle the error by way of a CATCH block if the method call does not contain the NO-ERROR option.
If the error is not trapped by a NO-ERROR option or a CATCH block, or handled by an explicit ON ERROR phrase or UNDO statement, then the AVM executes the default error handling behavior for the block type containing the method call. For more information, see OpenEdge Development: Error Handling.
*A callback raises an error by using the RETURN statement ERROR option.
If this error situation occurs, parsing stops, the AVM raises an error, and the RETURN-VALUE is set to whatever string the RETURN statement included.
If NO-ERROR was specified, the AVM sets ERROR-STATUS:ERROR to TRUE and sets ERROR-STATUS:NUM-MESSAGES to zero.
You can also handle the error by way of a CATCH block if the method call does not contain the NO-ERROR option.
If NO-ERROR was 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 explicit ON ERROR phrase. For more information, see OpenEdge Development: Error Handling.
Note: If a callback procedure calls a second procedure, the second procedure calls a third procedure, and so on, and the final procedure in the chain executes RETURN ERROR, each preceding procedure in the chain must also execute RETURN ERROR, otherwise the error condition is never communicated to the driver routine. This is standard AVM behavior.
*While a callback is executing, the AVM raises an error that the callback does not handle; for example, a FIND CUSTOMER that 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 PROCEDURE block) and behaves according to the block's explicit or implicit ON ERROR phrase. This might cause the AVM to break out of the callback.
*The PARSE-STATUS attribute and the ERROR-STATUS handle are unaffected.
*The parse continues.