|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
java.lang.Exception
com.rubecula.util.LocalizedException
Abstract exception class used for localizable exceptions.
Note that in order to retrieve the (non-localizable) detail message, call getMessage()
Field Summary | |
protected static java.lang.String |
$CausedBy
Value: "caused by" |
protected static java.lang.String |
$Colon
Value: ":" |
protected static java.lang.String |
$FurtherDetail
Value: "with further detail" |
protected static java.lang.String |
$Indent
Value: " " |
protected static java.lang.String |
$Newline
Value: "\n" |
protected static java.lang.String |
$NoLocalizableExplanation
Value: " (unspecified detail)" |
protected static java.lang.String |
$StackCallPrefix
Value: "\tat " |
protected static java.lang.String |
$ThrownBy
Value: " thrown by " |
protected static java.lang.String |
$UnknownMethod
Value: "unknown class/method" |
protected java.lang.String |
nonLocalJunk
The non-localizable junk from the key provided (characters from ":" to end inclusive, if any) |
private java.lang.String |
strClassMethod
A field which simply retains the value of the class and method names concatenated together by ".". |
protected java.lang.String |
strKey
The resource-specifying key for this exception |
Fields inherited from class java.lang.Exception |
|
Fields inherited from class java.lang.Throwable |
|
Constructor Summary | |
protected |
LocalizedException()
You must specify either the text message. |
|
LocalizedException(java.lang.String key)
Construct an exception with the key to the problem. |
|
LocalizedException(java.lang.String key,
java.lang.String detailNonLocalized)
Construct an exception with the key to the problem and a non-localizable detail message. |
|
LocalizedException(java.lang.String key,
java.lang.Throwable cause)
Construct an exception with the key to the problem and a causal exception. |
Method Summary | |
static java.lang.String |
getCaller(java.lang.Throwable e)
Get the caller details of the thrower of an exception. |
static java.lang.String |
getCaller(java.lang.Throwable e,
int index)
Gets the string representing the indexth caller (stack frame) within the stack trace of an exception. |
static java.lang.String |
getCallerClassMethod(java.lang.Throwable e)
Get the class-method part of the caller string. |
java.lang.String |
getLocalizedMessage()
This method is used by the toString method and indirectly by the printStackTrace methods in order to get a representation of the exception. |
abstract java.util.ResourceBundle |
getResourceBundle()
Method to get a reference to the resource bundle for this class. |
static java.lang.String |
getStackDumpAsString(java.lang.Throwable e)
Utility method to return the current exception stack dump as a String. |
void |
printStackTrace(java.io.PrintStream s)
Prints this LocalizedException and its backtrace to the
specified print stream.
|
java.lang.String |
toString()
Returns a short description of this throwable object. |
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, setStackTrace |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String strKey
protected java.lang.String nonLocalJunk
private java.lang.String strClassMethod
protected static final java.lang.String $NoLocalizableExplanation
protected static final java.lang.String $FurtherDetail
protected static final java.lang.String $ThrownBy
protected static final java.lang.String $UnknownMethod
protected static final java.lang.String $CausedBy
protected static final java.lang.String $Indent
protected static final java.lang.String $Newline
protected static final java.lang.String $Colon
protected static final java.lang.String $StackCallPrefix
Constructor Detail |
public LocalizedException(java.lang.String key, java.lang.String detailNonLocalized)
printStackTrace(java.io.PrintStream)
but not by
Throwable.toString()
nor any of the other printStackTrace methods.
key
- A key to a localizable detail message.
May be null but it really ought not to be.
If it is null, all the string forms of the exception will simply
identify themselves by class name which is OK if you are using
a very explicit exception class, but if you're using a generic class
you will never know WHICH exception was thrown, where.
Also, if you are using an explicit exception class with a null key,
consider extending BaseException instead of LocalizedException.
detailNonLocalized
- This is extra information which is not localizable.public LocalizedException(java.lang.String key, java.lang.Throwable cause)
LocalizedException(String,String)
getStackDumpAsString(Throwable)
it correctly handles the case where cause is of class java.lang.reflect.InvocationTargetException
key
- A key to a localizable detail message.cause
- The exception which caused the problem.LocalizedException(String,String)
public LocalizedException(java.lang.String key)
key
- A key to a localizable detail message.
The key itself should be unique amongst the potential instances of
this exception class.LocalizedException(String,String)
protected LocalizedException()
Method Detail |
public abstract java.util.ResourceBundle getResourceBundle()
public java.lang.String getLocalizedMessage()
Before being looked up in the resource bundles, they key has any embedded spaces converted into underscores ("_"). Furthermore, any characters including and to the right of an equality (":") are not considered part of the resource key and are simply reattached to the localized value retrieved using the key.
public java.lang.String toString()
Throwable
object was
created
with an error message string,
then the result is the concatenation of three strings:
Throwable.getMessage()
method for this object
Throwable
object was java.lang.Throwable#toString()} created}
with no error message string, then the name of the actual class of
this object is returned.
Throwable
.public void printStackTrace(java.io.PrintStream s)
LocalizedException
and its backtrace to the
specified print stream.
s
- The print stream to print the stack trace topublic static java.lang.String getStackDumpAsString(java.lang.Throwable e)
e
- The exception being handled
public static java.lang.String getCaller(java.lang.Throwable e, int index) throws java.lang.RuntimeException
$StackCallPrefix
and a newline.
e
- The exception whose stack frame we wish to extract from.index
- The index specifying which stack frame we are interested in.
0 represents the top (i.e. the actual method which threw the exception).
com.truexchange.trumarket.System.ExceptionHandler.RuntimeException
- This will be thrown if the index was incorrectly specified or if there is some other
problem.
java.lang.RuntimeException
public static java.lang.String getCaller(java.lang.Throwable e)
getCaller(java.lang.Throwable,int)
with index of 0.
e
- The exception
getCaller(java.lang.Throwable,int)
for format details.
May be null.public static java.lang.String getCallerClassMethod(java.lang.Throwable e)
getCaller(java.lang.Throwable)
and then returns the portion in front of the "("
e
- The exception for which we want the thrower
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |