IBM Support

How to retrieve useful information from a BPEL exception ?

Question & Answer


Question

How to retrieve useful information from a BPEL exception ?

Answer

When developing a BPEL component in IBM Integration Designer you often have CatchAll handlers that need to process errors.
You can get the BPEL exception using this code in a Snippet inside your CatchAll handler:
com.ibm.bpe.api.BpelException bpelexception = getCurrentFaultAsException();

? Often the "real reason for the failure" is buried in the root cause of this BpelException, after Stacktrace information.?
One technique for getting the real reason for the failure is to use a common Java class that can traverse the BpelException.? Here is an example method that can be used from your CatchAll handler to get meaningful failure information:

??? private static final String REASON_FOR_FAILURE = "Reason for failure";

??? /**
?? ? * Parse the given BpelException and return as much useful information as possible
?? ? * @param bpelException
?? ? * @return String
?? ? */
?? ?public static String parseBpelException (BpelException bpelException)
?? ?{
?? ??? ?String faultInfo = null;
?? ??? ?if (bpelException != null)
?? ??? ?{
?? ??? ??? ?if (bpelException.getRootCause() != null)
?? ??? ??? ?{
?? ??? ??? ??? ?faultInfo = bpelException.getRootCause().getLocalizedMessage();
?? ??? ??? ???? if (faultInfo == null || faultInfo.trim().length() == 0) {
?? ??? ??? ??? ???? faultInfo = bpelException.getMessage() + ' ' + bpelException.getRootCause();
?? ??? ??? ??? ?}?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?faultInfo = bpelException.getFaultName() + ' ' +bpelException.getMessage();
?? ??? ??? ?}
?? ??? ?}
?? ??? ?if (faultInfo == null)
?? ??? ?{
?? ??? ??? ?faultInfo = "";
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?int indxReason = faultInfo.indexOf(REASON_FOR_FAILURE);
?? ??? ??? ?if (indxReason > 0)
?? ??? ??? ?{
?? ??? ??? ??? ?faultInfo = faultInfo.substring(indxReason);
?? ??? ??? ?}
?? ??? ?}
?? ??? ?return faultInfo;
?? ?}

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSQTW3","label":"IBM On Demand Consulting for Hybrid Cloud"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
08 December 2018

UID

ibm10778931