public class MbException extends Exception
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);
}
}
}
}
| Modifier and Type | Method and Description |
|---|---|
void |
addNestedException(MbException childException)
Adds an exception to the array of exception objects representing the children of
this exception in the hierarchy (exception list).
|
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 |
getLocalizedMessage()
Returns the localized text for 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.
|
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTracepublic String getClassName()
public Object[] getInserts()
public String getMessageKey()
public String getMessageSource()
public String getMethodName()
public String getTraceText()
public String getMessage()
getMessage in class Throwablepublic String getLocalizedMessage()
getLocalizedMessage in class Throwablepublic MbException[] getNestedExceptions()
public void addNestedException(MbException childException)