public abstract class CommonBaseException extends Exception
Modifier and Type | Field and Description |
---|---|
protected String |
errMsg |
protected static org.slf4j.Logger |
logger |
protected StringBuffer |
stackTrace |
Constructor and Description |
---|
CommonBaseException()
An empty constructor.
|
CommonBaseException(String errorMsg)
A constructor that takes an exception message identifier value.
|
CommonBaseException(String errorMsg,
Object[] params)
Constructor that takes an exception message identifer value and an object
array.
|
CommonBaseException(String errorMsg,
Object[] params,
Throwable chainedException)
A constructor that takes a exception message identifier, an object array,
and a chained exception.
|
CommonBaseException(String errorMsg,
Throwable chainedException)
Constructor that takes in a Exception Message ID and a chained Exception
The Exception Message as generated by the errorMsg parameter (described
below) is appended with the string returned by getMessage() of the
chained exception.
|
CommonBaseException(Throwable chainedException)
A constructor that takes in a chained exception
The Exception Message is set to the default error string returned by the
getDefaultErrMsg appended with the string
returned by getMessage() of the chained exception. |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getDefaultErrMsg()
Abstract method that should return a default String which will be
prepended to the input String arguement for an exception, if the
Properties file is not valid or the Properties file does not contain a
key-value pair with the input String as a key.
|
String |
getMessage()
Returns an error messge.
|
protected abstract Properties |
getProps()
Abstract method that should return an initialized Properties Object.
|
protected static void |
initProps(String fileName,
Properties properties,
Class currentClass)
A static function that should be called by all exception classes that
derive from this abstract base class, in the static section of their
definitions.
|
void |
printStackTrace()
Prints the StackTrace on System.err.
|
void |
printStackTrace(PrintStream s)
Prints the StackTrace onto the input PrintStream.
|
void |
printStackTrace(PrintWriter w)
Prints the StackTrace onto the input PrintWriter.
|
protected static org.slf4j.Logger logger
protected String errMsg
protected StringBuffer stackTrace
public CommonBaseException()
getDefaultErrMsg
.public CommonBaseException(String errorMsg)
errorMsg
- This parameter can either be a plain string or a valid key in
the Properties file returned by getProps
.
If it is a valid key then the string corresponding to its
value in the properties file is used as the exception message.
Further as this constructor does not take any object
parameters the exception Message in the properties file should
not contain any object format specifiers like {0} and so on.
If it is not a valid key or the properties file is null, this
string is treated as the exception message itself, after
prepending it with the default String returned by
getDefaultErrMsg
.public CommonBaseException(Throwable chainedException)
getDefaultErrMsg
appended with the string
returned by getMessage() of the chained exception.chainedException
- Any Object of Throwable type.public CommonBaseException(String errorMsg, Throwable chainedException)
errorMsg
- This parameter can either be a plain string or a valid key in
the Properties file returned by getProps
.
If it is a valid key then the String corresponding to its
value in the properties file is used as the Exception Message.
Further as this constructor does not take any object
parameters the exception Message in the properties file should
not contain any object format specifiers like {0} etc. If it
is not a valid key or the properties file is null, this string
is treated as the Exception Message itself, after prepending
it with the default String returned by
getDefaultErrMsg
.chainedException
- Any throwable object type.public CommonBaseException(String errorMsg, Object[] params)
errorMsg
- This parameter can either be a plain string or a valid key in
the properties file returned by getProps
.
If it is a valid key then the string corresponding to its
value in the properties file is used as the exception message.
Further as this constructor takes in an object[] params the
exception message in the properties file is expected to
contain some object format specifiers like {0} etc. If this
parameter is not a valid key or the properties file is null,
this string is treated as the exception message itself, after
prepending it with the default String returned by
getDefaultErrMsg
.params
- An object array that substitutes in place of the format
specifiers like {0}, {1} etc in the formatted message as
obtained from the properties file corresponding to the
errorMsg as the key. If the array contains more objects than
the format specifiers in the message the extra ones will be
ignored. If the array contains less number of objects then the
extra specifiers will be printed as is.public CommonBaseException(String errorMsg, Object[] params, Throwable chainedException)
errorMsg
- This parameter can either be a plain string or a valid key in
the Properties file returned by getProps
.
If it is a valid key then the String corresponding to its
value in the properties file is used as the Exception Message.
Further as this constructor takes in an object[] params the
exception Message in the properties file is expected to
contain some object format specifiers like {0} etc. If this
parameter is not a valid key or the properties file is null,
this string is treated as the Exception Message itself, after
prepending it with the default String returned by
getDefaultErrMsg
.params
- an array of Objects which will be substituted in place of the
format specifiers like {0}, {1} etc in the formatted message
as obtained from the properties file corresponding to the
errorMsg as the key. If the array contains more objects than
the format specifiers in the message the extra ones will be
ignored. If the array contains less number of objects then the
extra specifiers will be printed as is.chainedException
- Any throwable object type.protected abstract Properties getProps()
protected abstract String getDefaultErrMsg()
public String getMessage()
getMessage
in class Throwable
public void printStackTrace()
printStackTrace
in class Throwable
public void printStackTrace(PrintStream s)
printStackTrace
in class Throwable
public void printStackTrace(PrintWriter w)
printStackTrace
in class Throwable
protected static void initProps(String fileName, Properties properties, Class currentClass)
getProps
function.fileName
- The name of the file which contains the key-value pairs
corresponding to the unique MessageIds used while throwing
exceptions and their corresponding localised Exception Messages.
This file is searched in the same location where the class
definition of the input arguement current class is available.properties
- The properties object that will be initialised with the
contents of the file pointed to by fileNamecurrentClass
- The class relative to which the file pointed to by fileName
will be searched.Copyright © 1982–2022 Adobe Systems Inc.. All rights reserved.