Package com.ibm.websphere.exception
Class DistributedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.ibm.websphere.exception.DistributedException
- All Implemented Interfaces:
DistributedExceptionEnabled
,Serializable
- Direct Known Subclasses:
ExceptionInstantiationException
Provides exception functions desirable in a distributed environment. This
includes the following:
- Support to allow exceptions to be chained, in the situation where multiple exceptions are thrown during a series of method calls.
- Saving stack trace information so that printStackTrace() will provide the stack trace of all chained exceptions.
- Methods to retrieve specific exceptions in the chain.
- Support for localized messages.
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor.DistributedException
(String message) Constructor with a message.DistributedException
(String resourceBundleName, String resourceKey, Object[] formatArguments, String defaultText) Constructor with localization message information.DistributedException
(String resourceBundleName, String resourceKey, Object[] formatArguments, String defaultText, Throwable exception) Constructor with localization message information and an exception to be chained.DistributedException
(String message, Throwable exception) Constructor with a message and an exception to be chained.DistributedException
(Throwable exception) Constructor with an exception to be chained. -
Method Summary
Modifier and TypeMethodDescriptiongetException
(String exceptionClassName) Get a specific exception in a possible chain of exceptions.Retrieve the DistributedExceptionInfo object.Retrieve the text message for this exception.Get the original exception in a possible chain of exceptions.Get the previous exception.void
Print the exception execution stack.void
Print the exception execution stack.void
Print the exception execution stack to a print writer.void
This method is used to get the stack trace of the current exception.void
This method is used to get the stack trace of the current exception.void
setDefaultMessage
(String defaultText) Set the default message for this message.void
setLocalizationInfo
(String resourceBundleName, String resourceKey, Object[] formatArguments) Set the values to be used for finding the correct translated version of the message and formatting it.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
-
Constructor Details
-
DistributedException
public DistributedException()Default constructor. -
DistributedException
Constructor with a message.- Parameters:
message
- java.lang.String Message text
-
DistributedException
public DistributedException(String resourceBundleName, String resourceKey, Object[] formatArguments, String defaultText) Constructor with localization message information.- Parameters:
resourceBundleName
- java.lang.String The name of resource bundle that will be used to retrieve the message for getMessage().resourceKey
- java.lang.String The key in the resource bundle that will be used to select the specific message that is retrieved for getMessage().formatArguments
- java.lang.Object[] The arguments to be passed to the MessageFormat class to act as replacement variables in the message that is retrieved from the resource bundle. Valid types are those supported by MessageFormat.defaultText
- java.lang.String The default message that will be used in getMessage() if the resource bundle or the key cannot be found.- See Also:
-
DistributedException
public DistributedException(String resourceBundleName, String resourceKey, Object[] formatArguments, String defaultText, Throwable exception) Constructor with localization message information and an exception to be chained.- Parameters:
resourceBundleName
- java.lang.String The name of resource bundle that will be used to retrieve the message for getMessage().resourceKey
- java.lang.String The key in the resource bundle that will be used to select the specific message that is retrieved for getMessage().formatArguments
- java.lang.Object[] The arguments to be passed to the MessageFormat class to act as replacement variables in the message that is retrieved from the resource bundle. Valid types are those supported by MessageFormat.defaultText
- java.lang.String The default message that will be used in getMessage() if the resource bundle or the key cannot be found.exception
- java.lang.Throwable The exception that is to be chained.- See Also:
-
DistributedException
Constructor with a message and an exception to be chained.- Parameters:
message
- The message for this exceptionexception
- java.lang.Throwable The exception to be chained
-
DistributedException
Constructor with an exception to be chained.- Parameters:
exception
- java.lang.Throwable The exception to be chained
-
-
Method Details
-
getException
Get a specific exception in a possible chain of exceptions. If there are multiple exceptions in the chain, the most recent one thrown will be returned. If the exceptions does not exist or no exceptions have been chained, null will be returned.- Specified by:
getException
in interfaceDistributedExceptionEnabled
- Parameters:
String
- exceptionClassName the class name of the specific exception.- Returns:
- java.lang.Throwable The specific exception in a chain of exceptions. If no exceptions have been chained, null will be returned.
- Throws:
ExceptionInstantiationException
- An exception occurred while trying to instantiate the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method followed by recursively using the getPreviousExceptionInfo() method on the DistributedExceptionInfo object.
-
getExceptionInfo
Retrieve the DistributedExceptionInfo object. This object is primarily used by a CORBA, non-Java client. It also may be used by a Java client to retrieve information about a previous exception when the getPreveiousException() method throws an exception.- Specified by:
getExceptionInfo
in interfaceDistributedExceptionEnabled
- Returns:
- com.ibm.websphere.exception.DistributedExceptionInfo
-
getMessage
Retrieve the text message for this exception. If a resource bundle and resource key have been previously specified when the exception was created, an attempt will be made to retrieve the message from the resource bundle for the language associated with the current locale. The default message (which may be null) will be returned in any of the following situations:- No resource bundle name exists
- No resource key exists
- The resource bundle could not be found
- The key was not found in the resource bundle
- Specified by:
getMessage
in interfaceDistributedExceptionEnabled
- Overrides:
getMessage
in classThrowable
- Returns:
- java.lang.String message for this exception
-
getOriginalException
Get the original exception in a possible chain of exceptions. If no previous exceptions have been chained, null will be returned.- Specified by:
getOriginalException
in interfaceDistributedExceptionEnabled
- Returns:
- java.lang.Throwable The first exception in a chain of exceptions. If no exceptions have been chained, null will be returned.
- Throws:
ExceptionInstantiationException
- An exception occurred while trying to instantiate the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method followed by recursively using the getPreviousExceptionInfo() method on the DistributedExceptionInfo object.
-
getPreviousException
Get the previous exception.- Specified by:
getPreviousException
in interfaceDistributedExceptionEnabled
- Returns:
- java.lang.Throwable The previous exception. If there was no previous exception, null will be returned. .
- Throws:
ExceptionInstantiationException
- An exception occurred while trying to instantiate the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method.
-
printStackTrace
public void printStackTrace()Print the exception execution stack. This will include the stack trace of where the exception was created, as well as the stack traces of previous exceptions in the exception chain.- Specified by:
printStackTrace
in interfaceDistributedExceptionEnabled
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
Print the exception execution stack to a print writer. This will include the stack trace of where the exception was created, as well as the stack traces of previous exceptions in the exception chain.- Specified by:
printStackTrace
in interfaceDistributedExceptionEnabled
- Overrides:
printStackTrace
in classThrowable
- Parameters:
pw
- java.io.PrintWriter
-
printStackTrace
Print the exception execution stack. This will include the stack trace of where the exception was created, as well as the stack traces of previous exceptions in the exception chain.- Overrides:
printStackTrace
in classThrowable
- Parameters:
pw
- java.io.PrintStream
-
printSuperStackTrace
This method is used to get the stack trace of the current exception. This method is called by DistributedExceptionInfo to retrieve and save the current stack trace. The information is saved and can be retrieved by printStackTrace();- Specified by:
printSuperStackTrace
in interfaceDistributedExceptionEnabled
- Parameters:
param
- java.io.PrintWriter
-
printSuperStackTrace
This method is used to get the stack trace of the current exception. This method is called by DistributedExceptionInfo to retrieve and save the current stack trace. The information is saved and can be retrieved by printStackTrace();- Parameters:
param
- java.io.PrintStream
-
setDefaultMessage
Set the default message for this message. This will be the message returned by getMessage() in any of the following situations:- Parameters:
defaultText
- java.lang.String
-
setLocalizationInfo
public void setLocalizationInfo(String resourceBundleName, String resourceKey, Object[] formatArguments) Set the values to be used for finding the correct translated version of the message and formatting it.- Parameters:
resourceBundleName
- java.lang.String - the name of the resource bundle, which is a subclass of java.util.PropertyResourceBundle.resourceKey
- java.lang.String - the key in the resource bundle that specifies the text for the exception messagearguments
- java.lang.Object[] -the arguments used to format the message. Valid values are those that are allowed for java.text.MessageFormat.format().- See Also:
-