Accessing the ExceptionList tree using Java
The ExceptionList tree is created with the logical tree when an input message is parsed.
About this task
The tree is initially empty, and is only populated if an exception occurs during message flow processing. It is possible that more than one exception can occur; if more than one exception occurs, the ExceptionList tree contains a subtree for each exception.
You
can access the ExceptionList tree in JavaCompute nodes from the MbMessageAssembly
parameter
of your evaluate()
method.
You can access the ExceptionList tree in a node in an error handling procedure. For example, you might want to route the message to a different path based on the type of exception.
//
)
of XPath gives you the ability to search for an element by name regardless
of its depth in the tree. For example: //ParserException
returns
all elements in the tree named ParserException
. //ParserException[Number=5016]
returns
only the exception that contains Number=5016
.java.lang.String
: string(//ParserException[Number=5016]/Text)
The following Java™ code extracts this text from your code:
String text =
(String)inAssembly.getExceptionList().evaluateXPath("string(//ParserException[Number=5016]/Text)");
For information on accessing the ExceptionList tree using ESQL, see Accessing the ExceptionList tree using ESQL.