Package com.sun.identity.common
Class ChainedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.sun.identity.common.ChainedException
-
- All Implemented Interfaces:
L10NMessage,Serializable
- Direct Known Subclasses:
DelegationException
public class ChainedException extends Exception implements L10NMessage
Base class for supporting chaining of exceptions.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ChainedException()No argument constructorChainedException(String message)ConstructorChainedException(String rbName, String errorCode, Object[] args, Throwable nestedException)Constructor Constructs an instance ofChainedExceptionto pass the localized error message At this level, the locale of the caller is not known and it is not possible to throw localized error message at this level.ChainedException(String message, Throwable nestedException)ConstructorChainedException(Throwable nestedException)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCompleteL10NMessage(Locale locale)Returns localized error message.StringgetErrorCode()Use this method to chain this exception with another to get localized error messge use getL10NMessage methodStringgetL10NMessage(Locale locale)Returns localized error message.StringgetMessage()Gets messages of the exceptions including the chained exceptionsObject[]getMessageArgs()Use this method to chain this exception with another to get localized error messge use getL10NMessage methodStringgetResourceBundleName()Returns resource bundle name associated with this error message.voidprintStackTrace()Prints the stack trace of the root exception to standard error stream.voidprintStackTrace(PrintStream ps)Prints the stack trace of the root exception to a PrintStream Also prints the messages of all the exceptions starting from top exception to the root exception, at the top of stack tracevoidprintStackTrace(PrintWriter pw)Prints the stack trace of the root exception to a PrintWriter Also prints the messages of all the exceptions starting from top exception to the root exception, at the top of stack trace-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
-
-
-
-
Constructor Detail
-
ChainedException
public ChainedException()
No argument constructor
-
ChainedException
public ChainedException(String message, Throwable nestedException)
Constructor- Parameters:
message- String message of this exceptionnestedException- Throwable nested in this exception
-
ChainedException
public ChainedException(Throwable nestedException)
Constructor- Parameters:
nestedException- Throwable nested in this exception
-
ChainedException
public ChainedException(String message)
Constructor- Parameters:
message- String message of this exception
-
ChainedException
public ChainedException(String rbName, String errorCode, Object[] args, Throwable nestedException)
Constructor Constructs an instance ofChainedExceptionto pass the localized error message At this level, the locale of the caller is not known and it is not possible to throw localized error message at this level. Instead this constructor provides Resource Bundle name and errorCode for correctly locating the error messsage. The default getMessage() will always return English messages only. This is consistent with current JRE- Parameters:
rbName- - ResourceBundle Name to be used for getting localized error message.errorCode- - Key to resource bundle. You can use ResourceBundle rb = ResourceBunde.getBundle (rbName,locale); String localizedStr = rb.getString(errorCode)args- - arguments to message. If it is not present pass them as nullnestedException- - The root cause of this exception
-
-
Method Detail
-
getL10NMessage
public String getL10NMessage(Locale locale)
Returns localized error message.- Specified by:
getL10NMessagein interfaceL10NMessage- Parameters:
locale- Input locale.- Returns:
- localized error message.
- See Also:
ChainedException(String, String, Object[], Throwable)
-
getCompleteL10NMessage
public String getCompleteL10NMessage(Locale locale)
Returns localized error message.- Parameters:
locale- Input locale.- Returns:
- localized error message.
- See Also:
ChainedException(String, String, Object[], Throwable)
-
getResourceBundleName
public String getResourceBundleName()
Returns resource bundle name associated with this error message.- Specified by:
getResourceBundleNamein interfaceL10NMessage- Returns:
- resource bundle name associated with this error message.
- See Also:
ChainedException(String, String, Object[], Throwable),- to get localized error message
-
getErrorCode
public String getErrorCode()
Description copied from interface:L10NMessageUse this method to chain this exception with another to get localized error messge use getL10NMessage method- Specified by:
getErrorCodein interfaceL10NMessage- Returns:
- Error code associated with this error message.
- See Also:
ChainedException(String, String, Object[], Throwable),to get localized error message.
-
getMessageArgs
public Object[] getMessageArgs()
Description copied from interface:L10NMessageUse this method to chain this exception with another to get localized error messge use getL10NMessage method- Specified by:
getMessageArgsin interfaceL10NMessage- Returns:
- arguments for formatting this error message. You need to use MessageFormat class to format the message It can be null.
- See Also:
ChainedException(String, String, Object[], Throwable),to get localized error message.
-
getMessage
public String getMessage()
Gets messages of the exceptions including the chained exceptions- Specified by:
getMessagein interfaceL10NMessage- Overrides:
getMessagein classThrowable- Returns:
- messages of the exceptions including chained exceptions. The returned string is formed by contatnating messages of all the exceptions, with a new line separator, starting from this exception, all the way to the root exception, by following the chained exceptions.
-
printStackTrace
public void printStackTrace()
Prints the stack trace of the root exception to standard error stream. Also prints the messages of all the exceptions starting from top exception to the root exception, at the top of stack trace- Overrides:
printStackTracein classThrowable
-
printStackTrace
public void printStackTrace(PrintWriter pw)
Prints the stack trace of the root exception to a PrintWriter Also prints the messages of all the exceptions starting from top exception to the root exception, at the top of stack trace- Overrides:
printStackTracein classThrowable- Parameters:
pw- PrintWriter to which to print the stack trace
-
printStackTrace
public void printStackTrace(PrintStream ps)
Prints the stack trace of the root exception to a PrintStream Also prints the messages of all the exceptions starting from top exception to the root exception, at the top of stack trace- Overrides:
printStackTracein classThrowable- Parameters:
ps- PrintStream to which to print the stack trace
-
-