|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
java.lang.Exception
com.webmethods.portal.PortalException
public class PortalException
Basic class for all exceptions thrown inside the portal framework. This class supports "nested exceptions" concept, i.e. portal exceptions can wrap other thrown exceptions - this allows the system to propagate the execution stack trace, facilitating debugging.
try { // Some code throws exception here ... } catch (Exception exc) { throw new PortalException(exc); }
You may dynmically extend the PortalException by implementing the PortalException.IPortalExceptionDelegate
interface and registering your implementation with the portal.
The PortalException uses the registered delegate each time a new PortalException is constructed. It will invoke the IPortalExceptionDelegate.exceptionThrown function which gives the delegate an opprotunity to replace the original exception with a custom exception.
To register an exception delegate modify the setenv.bat/setenv.sh to have the following line:
set JAVA_OPTIONS=%JAVA_OPTIONS% -DportalException.delegate=your.exception.delegate.class.name
The following is a simple example of an IPortalExceptionDelegate:
import java.sql.SQLException;
public class SampleExceptionDelegate implements PortalException.IPortalExceptionDelegate {
public void initialize() {
}
public Throwable exceptionThrown(String message, Throwable target, PortalException portalException) {
return new CustomException(message, target);
}
public class CustomException extends Exception {
public CustomException(String message, Throwable cause) {
super(message, cause);
}
public String getMessage() {
Throwable t = getCause();
if (t == null) {
return super.getMessage();
}
if (t instanceof SQLException) {
return "SQLException: " + super.getMessage();
}
return "Unknown Exception:" + super.getMessage();
}
}
}
PortalException.IPortalExceptionDelegate
,
Serialized FormNested Class Summary | |
---|---|
static interface |
PortalException.IPortalExceptionDelegate
The PortalException uses the registered delegate each time a new PortalException is constructed. |
Field Summary | |
---|---|
protected static String |
CURRENT_ERROR_LIST
|
static String |
EXCEPTION_DELEGATE_CLASS_NAME
|
protected Object |
m_context
|
protected List |
m_errorList
|
protected boolean |
m_ignoreTargetMessage
|
protected boolean |
m_isExpected
|
protected boolean |
m_isLocalizable
|
protected Object[] |
m_messageArgs
|
protected IMessageInfo |
m_messageInfo
|
protected String |
m_messageKey
|
protected Class |
m_resBundleClass
|
protected Throwable |
m_target
|
protected static PortalException.IPortalExceptionDelegate |
s_portalExceptionDelegate
|
Constructor Summary | |
---|---|
protected |
PortalException()
Deprecated. |
|
PortalException(Class resourceBundleClass,
String messageKey)
Constructor to create a localized exception message. |
|
PortalException(Class resourceBundleClass,
String messageKey,
Object[] messageArgs)
Constructor to create a localized bundle. |
|
PortalException(String message)
Deprecated. |
|
PortalException(String message,
boolean isExpected)
Deprecated. |
|
PortalException(String message,
Throwable target)
Deprecated. |
|
PortalException(String message,
Throwable target,
boolean isExpected)
Deprecated. |
|
PortalException(Throwable target)
Construct exception instance with nested exception only. |
|
PortalException(Throwable target,
boolean isExpected)
Constructs exception with nested exception only. |
|
PortalException(Throwable target,
Class resourceBundleClass,
String messageKey)
Constructor to create a localized exception message. |
|
PortalException(Throwable target,
Class resourceBundleClass,
String messageKey,
Object[] messageArgs)
Constructor to create a localized bundle. |
Method Summary | |
---|---|
static void |
addDetailsMesasge(IMessageInfo messageInfo)
When an exception is about to be thrown, you might want to add an explanatory message to the exception. |
static void |
addDetailsMessage(String msg)
Deprecated. (use the new local specific) |
protected void |
checkExpected(Throwable thrown)
"inherit" expected flag from the specified exception |
Throwable |
getCause()
Get the thrown target exception if any was assigned |
Object |
getContext()
Get context object associated with the exception (if any). |
List |
getErrorList()
Return error list reference if any were created. |
List |
getErrorList(boolean localize)
Return error list reference if any were created. |
protected IGlobalProvider |
getGlobalProvider()
|
String |
getLocalizedMessage()
Localize the message |
String |
getMessage()
Returns a message from the exception. |
String |
getMessageKey()
|
Throwable |
getTargetException()
Get the thrown target exception if any was assigned |
protected void |
initDetailsMessage()
Initializes details message list. |
boolean |
isExpected()
Identifies whether particular exception was expected or not. |
static PortalException |
notImplemented(String methodName)
Allows throwing "not implemented" exception. |
void |
printFullStackTrace()
Overridden behavior of Exception . |
void |
printFullStackTrace(PrintWriter s)
Overridden behavior of Exception . |
void |
printStackTrace()
Overridden behavior of Exception . |
void |
printStackTrace(PrintStream s)
Overridden behavior of Exception . |
void |
printStackTrace(PrintWriter s)
Overridden behavior of Exception . |
static void |
reset()
Resets any error messages. |
static PortalException |
reuseOrWrapException(Throwable t)
|
void |
setContext(Object context)
Assigns context object to provide additional information about exception (if necessary). |
void |
setExpected(boolean value)
Specify whether particular exception was expected or not. |
void |
setIgnoreTargetMessage(boolean value)
Specify whether the exception error message should ignore the target exception. |
Methods inherited from class java.lang.Throwable |
---|
fillInStackTrace, getStackTrace, initCause, setStackTrace, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String EXCEPTION_DELEGATE_CLASS_NAME
protected static final String CURRENT_ERROR_LIST
protected Throwable m_target
protected Object m_context
protected List m_errorList
protected boolean m_isExpected
protected boolean m_isLocalizable
protected Class m_resBundleClass
protected String m_messageKey
protected Object[] m_messageArgs
protected boolean m_ignoreTargetMessage
protected transient IMessageInfo m_messageInfo
protected static PortalException.IPortalExceptionDelegate s_portalExceptionDelegate
PortalException.IPortalExceptionDelegate
Constructor Detail |
---|
public PortalException(Throwable target)
target
- Nested exceptionpublic PortalException(Throwable target, boolean isExpected)
target
- Nested exceptionisExpected
- Expected exception flagpublic PortalException(Class resourceBundleClass, String messageKey)
ResourceBundle
will be inferred from the source
paramter
The messageKey will be used to obtain the correct localized message
public PortalException(Class resourceBundleClass, String messageKey, Object[] messageArgs)
ResourceBundle
will be inferred from the source
paramter
The messageKey will be used to obtain the correct localized message
The messageArgs will be used to format the messag
public PortalException(Throwable target, Class resourceBundleClass, String messageKey)
ResourceBundle
will be inferred from the source
paramter
The messageKey will be used to obtain the correct localized message
public PortalException(Throwable target, Class resourceBundleClass, String messageKey, Object[] messageArgs)
ResourceBundle
will be inferred from the source
paramter
The messageKey will be used to obtain the correct localized message
The messageArgs will be used to format the messag
protected PortalException()
public PortalException(String message, Throwable target, boolean isExpected)
message
- Exception messagetarget
- Nested exceptionisExpected
- Expected exception flagpublic PortalException(String message)
message
- Exception messagepublic PortalException(String message, boolean isExpected)
message
- Exception messageisExpected
- Expected exception flagpublic PortalException(String message, Throwable target)
message
- Exception messagetarget
- Nested exceptionMethod Detail |
---|
public Throwable getTargetException()
PortalException.m_target
public Throwable getCause()
getCause
in class Throwable
PortalException.m_target
public String getMessage()
getMessage
in class Throwable
public String getMessageKey()
public String getLocalizedMessage()
getLocalizedMessage
in class Throwable
public void printStackTrace(PrintWriter s)
Exception
. Prints stack trace to the
PrintWriter
. Overridden to allow Log4J to correctly print
wrapped exceptions. The trick is that when we have nested exception we should
print its stack trace instead of ours.
printStackTrace
in class Throwable
s
- PrintWriter instancepublic void printFullStackTrace(PrintWriter s)
Exception
. Overridden to allow Log4J to
correctly print wrapped exceptions. Uses default writer.
s
- PrintWriter instancepublic void printStackTrace(PrintStream s)
Exception
.
Prints stack trace to the PrintStream
. Overridden to
allow Log4J to correctly print wrapped exceptions.
printStackTrace
in class Throwable
s
- PrintStream instancepublic void printStackTrace()
Exception
. Overridden to
allow Log4J to correctly print wrapped exceptions. Uses default writer.
printStackTrace
in class Throwable
public void printFullStackTrace()
Exception
.
Overridden to allow Log4J to correctly print wrapped exceptions.
Uses default writer.
public void setIgnoreTargetMessage(boolean value)
value
- true to ignore the target exception message, false otherwisepublic void setExpected(boolean value)
value
- whether exception is expected or notpublic boolean isExpected()
protected void checkExpected(Throwable thrown)
thrown
- Exception instance to inherit expected flagpublic Object getContext()
public void setContext(Object context)
context
- Context object referencepublic List getErrorList()
public List getErrorList(boolean localize)
public static PortalException notImplemented(String methodName)
throw PortalException.notImplemented("SomeObject.someMethod");
methodName
- Signature of the method to be implemented
PortalException
to throw furtherpublic static void addDetailsMesasge(IMessageInfo messageInfo)
Unfortunately, you might not be in the code firing the exception, but in the code that clearly understands the details of the exception.
If so, add your message to the exception (to be thrown by you or someone else) with this API.
The constructor of the PortalException will gather these up and expose them with the call:
PortalException.getErrorList()
messageInfo
- Message to add to error listIMessageInfo
public static void addDetailsMessage(String msg)
Unfortunately, you might not be in the code firing the exception, but in the code that clearly understands the details of the exception.
If so, add your message to the exception (to be thrown by you or someone else) with this API.
The constructor of the PortalException will gather these up and expose them with the call:
PortalException.getErrorList()
msg
- Message to add to error listpublic static void reset()
PortalException.addDetailsMessage(java.lang.String)
protected void initDetailsMessage()
protected IGlobalProvider getGlobalProvider()
public static PortalException reuseOrWrapException(Throwable t)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |