Structured error handling example
- Last Updated: June 1, 2021
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The code in the following example:
- Encloses the logic in a simple block to demonstrate the placement and syntax of the
CATCHblock. In this simple example, if an error other than a system error occurred in the block, the error would be thrown to the enclosing block, which is the main block of the procedure (.p) file. - Handles any
Progress.Lang.SoapFaultErrorerror object generated by the AVM with the firstCATCHblock. This class is essentially a wrapper for the built-in SOAP-fault object. - Assigns a handle variable (
hSoapFault) to the SOAP-fault object returned by the AVM for code readability. - Examines the values of SOAP fault elements, as required, using appropriate attributes
(
SOAP-FAULT-CODE) on the SOAP-fault object handle. - Uses the ABL
VALID-HANDLEfunction to determine if this SOAP fault has SOAP fault detail by testing the validity of the handle returned byhSoapFault:SOAP-FAULT-DETAIL. - Assigns a handle variable (
hSoapFaultDetail) to the SOAP fault-detail object returned by thehSoapFault:SOAP-FAULT-DETAILattribute for code readability. - Returns the root node of the underlying SOAP fault
<detail>element by using thehSoapFaultDetail:GET-NODE()method to assign the root node to the x-noderef object referenced by the handle variablehxnoderef. - Use the methods and attributes of the X-noderef object handle (
hxnoderef) and additional handle variables to walk the XML DOM subtree referenced byhxnoderefto examine the content of the SOAP fault<detail>element as specified by the WSDL for the Web service. - Delete or throw the error object in the application code once it is handled by a
CATCHblock. Unhandled error objects are deleted automatically by the AVM. - Handles any system error (other than
SoapFaultError) raised in theON ERRORblock with the secondCATCHblock. BecauseSoapFaultErroris a subtype ofSysError, theCATCHblock handlingSoapFaultErrormust occur before the more generalCATCHblock for allSysErrorobjects. - Executes the
FINALLYblock whether the secondCATCHblock succeeded or failed. This makes theFINALLYblock a good place to put clean up code.
Sample SOAP fault procedure
|