java.lang.Object java.lang.Throwable java.lang.Exception com.ibm.broker.plugin.MbException
public class MbException
extends Exception
This is the base class of the exception hierarchy from which all exceptions are derived. An MbException object represents a single item within an exception list. An exception list is a hierarchy of exceptions which grow as error conditions get passed back up through the message flow. Despite the name, an exception list is, in fact, a tree structure with each exception able to have more than one child. It is possible to traverse the exception hierarchy within an exception handler in a Java user-defined node by calling getNestedExceptions in a recursive manner.
Example usage:
public void evaluate(MbMessageAssembly assembly, MbInputTerminal inTerm) throws MbException { try { // plug-in functionality } catch(MbException ex) { traverse(ex, 0); throw ex; // if re-throwing, it must be the original exception that was caught } } void traverse(MbException ex, int level) { if(ex != null) { // Do whatever action here System.out.println("Level: " + level); System.out.println(ex.toString()); System.out.println("traceText: " + ex.getTraceText()); // traverse the hierarchy MbException e[] = ex.getNestedExceptions(); int size = e.length; for(int i = 0; i < size; i++) if( ex instanceof MbJavaException ) { System.out.println("Level: " + level); System.out.println(((MbJavaException)ex).getThrowable().toString()); } else { // Do whatever action here System.out.println("Level: " + level); System.out.println(ex.toString()); System.out.println("traceText: " + ex.getTraceText()); // traverse the hierarchy MbException e[] = ex.getNestedExceptions(); int size = e.length; for(int i = 0; i < size; i++) { traverse(e[i], level + 1); } } } }
Method | Description |
---|---|
String getClassName() | Returns the class name of the object that generated the exception. |
Object[] getInserts() | Returns the object array containing the inserts in the message. |
String getMessage() | Returns the full message with inserts. |
String getMessageKey() | Returns the key to the message in the exception. |
String getMessageSource() | Returns the source of the message in the exception. |
String getMethodName() | Returns the name of the method which threw the exception. |
MbException[] getNestedExceptions() | Returns an array of exception objects representing the children of this exception in the hierarchy (exception list). |
String getTraceText() | Returns the trace text. |
String toString() | Returns the String representation of the exception. |
public String getClassName()Returns the class name of the object that generated the exception.
- Returns
- The string containing the name of the class which generated the exception.
public Object[] getInserts()Returns the object array containing the inserts in the message.
- Returns
- The Object array containing the inserts in the message.
public String getMessage()Returns the full message with inserts.
- Returns
- The full message.
- Overrides
- getMessage in class Throwable
public String getMessageKey()Returns the key to the message in the exception.
- Returns
- The key to the message in the exception.
public String getMessageSource()Returns the source of the message in the exception.
- Returns
- The source of the message in the exception.
public String getMethodName()Returns the name of the method which threw the exception.
- Returns
- The name of the method which generated the exception.
public MbException[] getNestedExceptions()Returns an array of exception objects representing the children of this exception in the hierarchy (exception list). Each element will be of the correct exception type (e.g. MbDatabaseException for a database error). If the current exception has no children, an empty array will be returned.
- Returns
- An array of nested exceptions
public String getTraceText()Returns the trace text.
- Returns
- The text of the extra message in the exception.
public String toString()Returns the String representation of the exception.
- Returns
- A String representation of the exception.
- Overrides
- toString in class Throwable