public abstract class AbstractException extends java.lang.Exception implements ICodedException
This checked exception class is designed as a base/expansion point for the entire hierarchy of checked exceptions in a project.
It provides the following features:
AbstractRuntimeException for an unchecked version of the same class.
TODO: javadoc
Each constructor that accepts a String 'message' parameter accepts an error
code as well. You are then responsible for ensuring that either the root
com.vladium.exception.exceptions resource bundle
or your project/exception class-specific resource bundle [see
below for details] contains a mapping for this error
code. When this lookup fails the passed String value itself will be used as
the error message.
All constructors taking an 'arguments' parameter supply parameters to the error message used as a java.text.MessageFormat pattern.
Example:
File file = ...
try
...
catch (Exception e)
{
throw new AbstractException ("FILE_NOT_FOUND", new Object[] {file, e}, e);
}
where com.vladium.util.exception.exceptions contains:
FILE_NOT_FOUND: file {0} could not be opened: {1}
To log exception data use getMessage() or printStackTrace
family of methods. You should never have to use toString().| 构造器和说明 |
|---|
AbstractException()
Constructs an exception with null message and null cause.
|
AbstractException(java.lang.String message)
Constructs an exception with given error message/code and null cause.
|
AbstractException(java.lang.String message,
java.lang.Object[] arguments)
Constructs an exception with given error message/code and null cause.
|
AbstractException(java.lang.String message,
java.lang.Object[] arguments,
java.lang.Throwable cause)
Constructs an exception with given error message/code and given cause.
|
AbstractException(java.lang.String message,
java.lang.Throwable cause)
Constructs an exception with given error message/code and given cause.
|
AbstractException(java.lang.Throwable cause)
Constructs an exception with null error message/code and given cause.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
__printStackTrace(java.io.PrintStream ps)
Every exception hierarchy implementing this interface must ensure that
this method delegates to super.printStackTrace(ps) where 'super' is the
first superclass not implementing IThrowableWrapper.
|
void |
__printStackTrace(java.io.PrintWriter pw)
Every exception hierarchy implementing this interface must ensure that
this method delegates to super.printStackTrace(pw) where 'super' is the
first superclass not implementing IThrowableWrapper.
|
static void |
addExceptionResource(java.lang.Class namespace,
java.lang.String messageResourceBundleName)
Equivalent to
ExceptionCommon.addExceptionResource(java.lang.Class, java.lang.String), repeated here for
convenience. |
java.lang.Throwable |
getCause()
This implements
IThrowableWrapper
and also overrides the base method in JDK 1.4+. |
java.lang.String |
getErrorCode()
Returns the String that was passed as 'message' constructor argument.
|
java.lang.String |
getLocalizedMessage()
Overrides base method for the sole purpose of making it final.
|
java.lang.String |
getMessage()
Overrides base method to support error code lookup and avoid returning nulls.
|
void |
printStackTrace()
Overrides Exception.printStackTrace() to (a) force the output to go
to System.out and (b) handle nested exceptions in JDKs prior to 1.4.
|
void |
printStackTrace(java.io.PrintStream s)
Overrides Exception.printStackTrace() to handle nested exceptions in JDKs prior to 1.4.
|
void |
printStackTrace(java.io.PrintWriter s)
Overrides Exception.printStackTrace() to handle nested exceptions in JDKs prior to 1.4.
|
public AbstractException()
public AbstractException(java.lang.String message)
message - the detail message [can be null]public AbstractException(java.lang.String message,
java.lang.Object[] arguments)
message - the detail message [can be null]arguments - message format parameters [can be null or empty]MessageFormatpublic AbstractException(java.lang.Throwable cause)
cause - the cause [nested exception] [can be null]public AbstractException(java.lang.String message,
java.lang.Throwable cause)
message - the detail message [can be null]cause - the cause [nested exception] [can be null]public AbstractException(java.lang.String message,
java.lang.Object[] arguments,
java.lang.Throwable cause)
message - the detail message [can be null]arguments - message format parameters [can be null or empty]cause - the cause [nested exception] [can be null]MessageFormatpublic final java.lang.String getMessage()
Equivalent to getLocalizedMessage().
getMessage 在类中 java.lang.Throwablepublic final java.lang.String getLocalizedMessage()
Equivalent to getMessage().
getLocalizedMessage 在类中 java.lang.Throwablepublic final void printStackTrace()
Subclasses cannot override.
printStackTrace 在类中 java.lang.Throwablepublic final void printStackTrace(java.io.PrintStream s)
Subclasses cannot override.
printStackTrace 在类中 java.lang.Throwablepublic final void printStackTrace(java.io.PrintWriter s)
Subclasses cannot override.
printStackTrace 在类中 java.lang.Throwablepublic final java.lang.String getErrorCode()
getErrorCode 在接口中 ICodedExceptionpublic final java.lang.Throwable getCause()
IThrowableWrapper
and also overrides the base method in JDK 1.4+.getCause 在类中 java.lang.Throwablepublic void __printStackTrace(java.io.PrintStream ps)
ExceptionCommon to avoid infinite
recursion and is not meant to be called by other classes.public void __printStackTrace(java.io.PrintWriter pw)
ExceptionCommon to avoid infinite
recursion and is not meant to be called by other classes.public static void addExceptionResource(java.lang.Class namespace,
java.lang.String messageResourceBundleName)
ExceptionCommon.addExceptionResource(java.lang.Class, java.lang.String), repeated here for
convenience. Subclasses should invoke from static initializers only.
'namespace' should be YourException.class.Copyright © 2018. All Rights Reserved.