org.teiid.core.util
Class ExceptionUtil

java.lang.Object
  extended by org.teiid.core.util.ExceptionUtil

public class ExceptionUtil
extends java.lang.Object

Utility class that provides some useful things for users of the com.metamatrix.api.exception package. Also provides package-level functionality that is shared among classes in this package.


Nested Class Summary
static class ExceptionUtil.NestedExceptionIterator
          An Iterator over any nested children Throwables of either a MetaMatrixException or a MetaMatrixRuntimeException.
 
Method Summary
static java.util.Iterator getChildrenIterator(java.lang.Throwable e)
          Convenience method that takes any Throwable and returns an appropriate Iterator over any nested exceptions in that Throwable.
static java.lang.String getLinkedMessages(java.lang.Throwable exception)
           
static java.lang.String getLinkedMessages(java.lang.Throwable exception, int level)
          Get the chain of messages, starting with the specified exception.
static java.lang.String getLinkedMessagesVerbose(java.lang.Throwable exception)
           
static java.lang.String getLinkedMessagesVerbose(java.lang.Throwable exception, int level)
           
static void printNestedStackTrace(java.lang.Throwable exception, java.io.PrintStream output)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getChildrenIterator

public static java.util.Iterator getChildrenIterator(java.lang.Throwable e)
Convenience method that takes any Throwable and returns an appropriate Iterator over any nested exceptions in that Throwable. Currently, only instances of MetaMatrixException and MetaMatrixRuntimeException are capable of nesting Throwables - calling this method in that case is equivalent to calling MetaMatrixException.getChildren() or MetaMatrixRuntimeException.getChildren(). Otherwise, a non-null "empty" Iterator is returned, one that simply has no Objects in it.

Parameters:
e - any Throwable
Returns:
an appropriate Iterator over any nested children Throwables;

printNestedStackTrace

public static void printNestedStackTrace(java.lang.Throwable exception,
                                         java.io.PrintStream output)

getLinkedMessagesVerbose

public static java.lang.String getLinkedMessagesVerbose(java.lang.Throwable exception)

getLinkedMessagesVerbose

public static java.lang.String getLinkedMessagesVerbose(java.lang.Throwable exception,
                                                        int level)

getLinkedMessages

public static java.lang.String getLinkedMessages(java.lang.Throwable exception)

getLinkedMessages

public static java.lang.String getLinkedMessages(java.lang.Throwable exception,
                                                 int level)
Get the chain of messages, starting with the specified exception. The level number in the chain is prepended.

This method calls the getMessage method for the exception passed in, and appends on the result returned from a recursive call to this method for the child of the passed in exception. The passed in exception is updated on each recursive call to be the child of the original exception, and the level is incremented on each call.

Parameters:
exception - The exception to print the chained message list of
level - (zero-based) The depth of the exception parameter in the chain of exceptions.
messageFormatter - the formatter of the message; may not be null
Returns:
A string of chained messages, each prepended by its level in the chain, and each followed by a newline (blank string if the exception passed in is null)
See Also:
Throwable.getMessage()


Copyright © 2011. All Rights Reserved.