org.teiid.test.framework.exception
Class QueryTestFailedException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.teiid.test.framework.exception.QueryTestFailedException
All Implemented Interfaces:
java.io.Serializable

public class QueryTestFailedException
extends java.lang.Exception
implements java.io.Serializable

The QueryTestFailedException is thrown during a test. This exception which contains a reference to another exception. This class can be used to maintain a linked list of exceptions.

Subclasses of this exception typically only need to implement whatever constructors they need.

See Also:
Serialized Form

Constructor Summary
QueryTestFailedException()
          Construct a default instance of this class.
QueryTestFailedException(java.lang.String message)
          Construct an instance with the specified error message.
QueryTestFailedException(java.lang.String code, java.lang.String message)
          Construct an instance with the specified error code and message.
QueryTestFailedException(java.lang.Throwable e)
          Construct an instance with a linked exception specified.
QueryTestFailedException(java.lang.Throwable e, java.lang.String message)
          Construct an instance with the linked exception and error message specified.
QueryTestFailedException(java.lang.Throwable e, java.lang.String code, java.lang.String message)
          Construct an instance with the linked exception, error code, and error message specified.
 
Method Summary
 java.lang.Throwable getChild()
          Get the exception which is linked to this exception.
static java.lang.String getClassShortName(java.lang.Class<?> cls)
          Utility method to get the name of a class, without package information.
 java.lang.String getCode()
          Get the error code.
 java.lang.String getFormattedMessage(java.lang.Throwable throwable, int level)
          Returns the error message, formatted for output.
 java.lang.String getFullMessage()
          Get the full error message, including any message(s) from child exceptions.
 java.lang.String getMessage()
           
 void setChild(java.lang.Throwable child)
          Set the exception which is linked to this exception.
 void setCode(java.lang.String code)
          Set the error code.
 java.lang.String toString()
          Returns a string representation of this class.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryTestFailedException

public QueryTestFailedException()
Construct a default instance of this class.


QueryTestFailedException

public QueryTestFailedException(java.lang.String message)
Construct an instance with the specified error message. If the message is actually a key, the actual message will be retrieved from a resource bundle using the key, the specified parameters will be substituted for placeholders within the message, and the code will be set to the key.

Parameters:
message - The error message or a resource bundle key

QueryTestFailedException

public QueryTestFailedException(java.lang.String code,
                                java.lang.String message)
Construct an instance with the specified error code and message. If the message is actually a key, the actual message will be retrieved from a resource bundle using the key, and the specified parameters will be substituted for placeholders within the message.

Parameters:
code - The error code
message - The error message or a resource bundle key

QueryTestFailedException

public QueryTestFailedException(java.lang.Throwable e)
Construct an instance with a linked exception specified. If the exception is a MetaMatrixException or a TeiidRuntimeException, then the code will be set to the exception's code.

Parameters:
e - An exception to chain to this exception

QueryTestFailedException

public QueryTestFailedException(java.lang.Throwable e,
                                java.lang.String message)
Construct an instance with the linked exception and error message specified. If the message is actually a key, the error message will be retrieved from a resource bundle the key, and code will be set to that key. Otherwise, if the specified exception is a MetaMatrixException or a TeiidRuntimeException, the code will be set to the exception's code.

Parameters:
e - The exception to chain to this exception
message - The error message or a resource bundle key

QueryTestFailedException

public QueryTestFailedException(java.lang.Throwable e,
                                java.lang.String code,
                                java.lang.String message)
Construct an instance with the linked exception, error code, and error message specified. If the message is actually a key, the error message will be retrieved from a resource bundle using the key.

Parameters:
e - The exception to chain to this exception
code - The error code
message - The error message or a resource bundle key
Method Detail

getClassShortName

public static java.lang.String getClassShortName(java.lang.Class<?> cls)
Utility method to get the name of a class, without package information.

Parameters:
cls - The class to get the name of
Returns:
The name of the class, without package info

getChild

public java.lang.Throwable getChild()
Get the exception which is linked to this exception.

Returns:
The linked exception

getCode

public java.lang.String getCode()
Get the error code.

Returns:
The error code

getFormattedMessage

public java.lang.String getFormattedMessage(java.lang.Throwable throwable,
                                            int level)
Returns the error message, formatted for output.

The default formatting provided by this method is to prepend the error message with the level and the name of the class, and to append the error code on the end if a non-zero code is defined.

This method provides a hook for subclasses to override the default formatting of any one exception.

Parameters:
except - The exception to print
level - The depth of the exception in the chain of exceptions
Returns:
A formatted string for the exception

getFullMessage

public java.lang.String getFullMessage()
Get the full error message, including any message(s) from child exceptions. Messages of any exceptions chained to this exception are prepended with their "level" in the chain.

Returns:
The full error message
See Also:
getFormattedMessage(java.lang.Throwable, int)

getMessage

public java.lang.String getMessage()
Overrides:
getMessage in class java.lang.Throwable

setChild

public void setChild(java.lang.Throwable child)
Set the exception which is linked to this exception.

For the special case of an InvocationTargetException, which is a wrapped exception provided in the java.lang.reflect package, the child is set to the wrapped exception, and the message, if not yet defined, is set to the message of the wrapped exception.

Parameters:
child - The linked exception

setCode

public void setCode(java.lang.String code)
Set the error code.

Parameters:
code - The error code

toString

public java.lang.String toString()
Returns a string representation of this class.

Overrides:
toString in class java.lang.Throwable
Returns:
String representation of instance


Copyright © 2010. All Rights Reserved.