uk.org.ogsadai.common.exception
Class DAIException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--uk.org.ogsadai.common.exception.DAIException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ActivityConfigurationException, AuthorisationException, CommonException, ConfigurationException, CoreException, DataServiceResourceException, DocumentValidationException, EngineException, ObjectCreationException, ResponseException, ToolException

public abstract class DAIException
extends java.lang.Exception

Base class for all OGSA-DAI exceptions which are to be presented to a user or OGSA-DAI administrator.

Instances of this class contain an mMessageNumber field and an mParams field. These are used in conjunction to uniquely identify an error message in the message bundle. mParams is an array of strings which are to be substituted into marked positions in message number mMessageNumber from the message bundle in the user's favourite language.

For OGSA-DAI exceptions which arise as a result of another exception being raised, the optional field mException can be used to contain this exception.

Author:
The OGSA-DAI Project Team
See Also:
Serialized Form

Field Summary
protected  java.lang.Throwable mException
          The exception which caused this exception to be thrown, if any.
protected  int mMessageNumber
          The index of the exception's message in the message bundle.
protected  java.lang.String[] mParams
          The parameters to substitute into the exception's message.
 
Constructor Summary
DAIException(int num, java.lang.Object[] params)
          Construct a new OGSA-DAI exception, using a specified message from the message bundle.
DAIException(int num, java.lang.Object[] params, org.apache.log4j.Logger logger)
          Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.
DAIException(int num, java.lang.Object[] params, java.lang.Throwable ex)
          Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.
DAIException(int num, java.lang.Object[] params, java.lang.Throwable cause, org.apache.log4j.Logger logger)
          Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.
 
Method Summary
 java.lang.Throwable getException()
          Return the exception which caused this exception to be thrown.
 java.lang.String getLocalizedMessage()
          A DAIException contains enough information to enable us to translate the message into any language.
 int getMessageNumber()
          Return the number of the message from the message bundle.
 java.lang.String[] getParams()
          Return the parameters to be substituted into the message at the appropriate positions.
static java.lang.String stackTraceToString(java.lang.Throwable ex)
          Utility method for retrieving the stacktrace as a String from an exception
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mMessageNumber

protected final int mMessageNumber
The index of the exception's message in the message bundle.


mParams

protected final java.lang.String[] mParams
The parameters to substitute into the exception's message.


mException

protected final java.lang.Throwable mException
The exception which caused this exception to be thrown, if any.

Constructor Detail

DAIException

public DAIException(int num,
                    java.lang.Object[] params)
Construct a new OGSA-DAI exception, using a specified message from the message bundle.

Parameters:
num - the index of the message in the message bundle
params - the parameters to substitute into the message, or null if the message expects no parameters

DAIException

public DAIException(int num,
                    java.lang.Object[] params,
                    java.lang.Throwable ex)
Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.

Parameters:
num - the index of the message in the message bundle
params - the parameters to substitute into the message, or null if the message expects no parameters
ex - the exception which caused this exception to be thrown

DAIException

public DAIException(int num,
                    java.lang.Object[] params,
                    org.apache.log4j.Logger logger)
Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.

Parameters:
num - the index of the message in the message bundle
params - the parameters to substitute into the message, or null if the message expects no parameters
logger - the logger to use to log the exception message

DAIException

public DAIException(int num,
                    java.lang.Object[] params,
                    java.lang.Throwable cause,
                    org.apache.log4j.Logger logger)
Construct a new OGSA-DAI exception, using a specified message from the message bundle, supplying an exception which caused this exception to be thrown.

Parameters:
num - the index of the message in the message bundle
params - the parameters to substitute into the message, or null if the message expects no parameters
cause - the exception which caused this exception to be thrown
logger - the logger to use to log the exception message
Method Detail

getLocalizedMessage

public java.lang.String getLocalizedMessage()
A DAIException contains enough information to enable us to translate the message into any language. This method extracts this information and uses it to return a description of the error in the default language of the current locale.

Overrides:
getLocalizedMessage in class java.lang.Throwable
Returns:
a description of the error in the current language

stackTraceToString

public static java.lang.String stackTraceToString(java.lang.Throwable ex)
Utility method for retrieving the stacktrace as a String from an exception

Parameters:
ex - The exception
Returns:
The stacktrace of the exception

getException

public java.lang.Throwable getException()
Return the exception which caused this exception to be thrown.

Returns:
the exception, or null if none was specified

getMessageNumber

public int getMessageNumber()
Return the number of the message from the message bundle.

Returns:
the message number

getParams

public java.lang.String[] getParams()
Return the parameters to be substituted into the message at the appropriate positions.

Returns:
the message's parameters