/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ChainedException.java,v 1.3 2008/06/25 05:42:25 qcheng Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/**
* Base class for supporting chaining of exceptions.
*/
.getInstance();
/**
* No argument constructor
*/
public ChainedException() {
}
/**
* Constructor
*
* @param message
* String message of this exception
* @param nestedException
* Throwable nested in this exception
*/
}
/**
* Constructor
*
* @param nestedException
* Throwable nested in this exception
*/
if (_nestedException instanceof L10NMessage) {
}
}
/**
* Constructor
*
* @param message
* String message of this exception
*/
}
/**
* Constructor Constructs an instance of <code> ChainedException </code> to
* 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
*
* @param rbName -
* ResourceBundle Name to be used for getting localized error
* message.
* @param errorCode -
* Key to resource bundle. You can use ResourceBundle rb =
* ResourceBunde.getBundle (rbName,locale); String localizedStr =
* rb.getString(errorCode)
* @param args -
* arguments to message. If it is not present pass them as null
* @param nestedException -
* The root cause of this exception
*/
}
/**
* Returns localized error message.
*
* @param locale
* Input locale.
* @see #ChainedException(String, String, Object[], Throwable)
* @return localized error message.
*/
} else {
}
}
return result;
}
/**
* Returns localized error message.
*
* @param locale
* Input locale.
* @see #ChainedException(String, String, Object[], Throwable)
* @return localized error message.
*/
} else {
}
}
if (_nestedException != null) {
if (_nestedException instanceof L10NMessage) {
} else {
}
}
if (chainedMessage != null) {
}
return result;
}
/**
* Returns resource bundle name associated with this error message.
*
* @see #ChainedException(String, String, Object[], Throwable)
* @see #getL10NMessage(java.util.Locale) - to get localized error message
* @return resource bundle name associated with this error message.
*/
return _bundleName;
}
/**
* @return Error code associated with this error message.
* @see #ChainedException(String, String, Object[], Throwable)
* @see #getL10NMessage(java.util.Locale) to get localized error message.
*/
return _errorCode;
}
/**
* @return arguments for formatting this error message. You need to use
* MessageFormat class to format the message It can be null.
* @see #ChainedException(String, String, Object[], Throwable)
* @see #getL10NMessage(java.util.Locale) to get localized error message.
*/
return _args;
}
/**
* Gets messages of the exceptions including the chained exceptions
*
* @return 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.
*/
if (_nestedException != null) {
}
if (chainedMessage != null) {
} else {
}
} else {
}
return message;
}
/**
* 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
*/
public void printStackTrace() {
}
/**
* 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
*
* @param pw
* PrintWriter to which to print the stack trace
*/
}
/**
* 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
*
* @param ps
* PrintStream to which to print the stack trace
*/
}
return _message;
}
/*
* We get the stack trace for the root exception. We prepend the class
* names and messages of all the exceptions starting from this exception
* to the root exception, as header. We number the exceptions in the
* header. TODO: We would like to cross reference the numbers from the
* header, on the stack trace lines, to show which line corresponds to
* the point at which the respective exception is thrown.
*/
int exCount = 1;
Throwable rootException = this;
while ((rootException instanceof ChainedException)
{
exCount++;
if (rootException instanceof ChainedException) {
} else {
}
}
if (rootException == this) {
} else {
// System.err.println(thisStackTrace.toString());
// System.err.println(rootStackTrace.toString());
// rootStackTrace.insert(thisStackTrace.length(), ">>");
// System.err.println(rootStackTrace.toString());
}
return stackString;
}
super.printStackTrace(pw);
}
}