public class GenericSerializableException extends RuntimeException implements NlsThrowable, NlsMessage
Throwable
via a remote service. Some exceptions
can not be serialized at all and others may not be de-serialized because they (or one of their cause
s or suppressed
exceptions) are an implementation secret and are therefore not in the
classpath on the other end. This exception allows to wrap any other kind of exception so the message
, code
, UUID
and stacktrace
are preserved while the other end only needs to know this exception class. However the original
type
of the exception is lost in the manner that catching, handling and instanceof-checks of the
actual exception will not work anymore.Modifier and Type | Field and Description |
---|---|
private String |
code |
private String |
originalExceptionName |
private static long |
serialVersionUID |
private boolean |
technical |
private UUID |
uuid |
LOCALIZATION_FAILURE_PREFIX
KEY_ANNOTATION, KEY_ARGUMENT, KEY_CAPACITY, KEY_CONTAINER, KEY_DEFAULT, KEY_DIRECTORY, KEY_ERROR, KEY_EXISTING, KEY_EXPECTED, KEY_FILE, KEY_FUNCTION, KEY_ID, KEY_KEY, KEY_LOCATION, KEY_MAX, KEY_MIN, KEY_MODE, KEY_NAME, KEY_OBJECT, KEY_OPERAND, KEY_OPERATION, KEY_OPTION, KEY_PATH, KEY_PROPERTY, KEY_QUERY, KEY_RESOURCE, KEY_SIZE, KEY_SOURCE, KEY_TARGET_TYPE, KEY_TITLE, KEY_TYPE, KEY_URI, KEY_USER, KEY_VALUE
Modifier | Constructor and Description |
---|---|
protected |
GenericSerializableException()
The constructor for de-serialization in GWT.
|
|
GenericSerializableException(Throwable cause,
String message,
String originalExceptionName,
StackTraceElement[] stacktrace,
boolean technical,
String code,
UUID uuid)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
GenericSerializableException |
createCopy(ExceptionTruncation truncation)
Returns a copy of the given exception where the specified details are removed.
|
Throwable |
fillInStackTrace()
Prevents creating a stacktrace.
|
Object |
getArgument(int index)
This method gets the language independent argument at the given
index . |
Object |
getArgument(String key)
This method gets the language independent argument value for the given
key . |
int |
getArgumentCount()
This method gets the number of language independent arguments of this exception.
|
String |
getCode()
This method gets the code that identifies the detailed type of this object.
|
String |
getInternationalizedMessage()
This method gets the internationalized message what is the actual message template for the
root
locale without resolving its NlsArgument s. |
String |
getLocalizedMessage(Locale locale)
This method gets the localized message as string.
|
void |
getLocalizedMessage(Locale locale,
Appendable appendable)
This method writes the localized message to the given string buffer.
|
String |
getLocalizedMessage(Locale locale,
NlsTemplateResolver resolver)
This method gets the localized message as string.
|
void |
getLocalizedMessage(Locale locale,
NlsTemplateResolver resolver,
Appendable buffer)
This method writes the localized message to the given
buffer . |
NlsMessage |
getNlsMessage()
This method gets the
NlsMessage describing the problem. |
String |
getOriginalExceptionName() |
UUID |
getUuid()
This method gets the
UUID of this object. |
boolean |
isForUser() |
boolean |
isTechnical()
Determines if this is a technical exception.
|
void |
printStackTrace(Locale locale,
Appendable buffer)
This method prints the stack trace with localized exception message(s).
|
NlsMessage |
toNlsMessage()
This method is the equivalent to
Object.toString() with native language support. |
String |
toString() |
String |
toString(Locale locale)
Like
NlsThrowable.toString() but using the specified Locale . |
Appendable |
toString(Locale locale,
Appendable appendable)
appends the localized string representation of this exception. |
addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCause, getStackTrace
getMessage
getLocalizedMessage, getMessage
private static final long serialVersionUID
private String originalExceptionName
private String code
private boolean technical
private UUID uuid
protected GenericSerializableException()
public GenericSerializableException(Throwable cause, String message, String originalExceptionName, StackTraceElement[] stacktrace, boolean technical, String code, UUID uuid)
cause
- - see Throwable.getCause()
. Should be a GenericSerializableException
.message
- - see Throwable.getMessage()
.originalExceptionName
- - see getOriginalExceptionName()
.stacktrace
- - the stacktrace
of the original exception.technical
- - see isTechnical()
.code
- - see getCode()
.uuid
- - see getUuid()
.public GenericSerializableException createCopy(ExceptionTruncation truncation)
NlsThrowable
ExceptionUtil
for
advanced usage and further details. createCopy
in interface NlsThrowable
truncation
- the ExceptionTruncation
to configure what to remove. E.g.
ExceptionTruncation.REMOVE_ALL
.exception
.public String getOriginalExceptionName()
public Throwable fillInStackTrace()
fillInStackTrace
in class Throwable
public String getCode()
AttributeReadMessageCode
UUID
or ID
are typically unique per instance of
an object the code is unique for all instances of the exact same kind. So e.g. a particular kind of
exception
or ValidationFailure
can be identified by its
code. A simple generic implementation may return the classname or the key of the NLS message. However, the code
should remain stable after refactoring (so at least after the rename the previous code should be returned as
String
literal). This code may be used as a compact identifier to reference the related problem or
information as well as for automatic tests of error situations that should remain stable even if the message text
gets improved or the locale is unknown.getCode
in interface AttributeReadMessageCode
Throwable.getMessage()
,
NlsThrowable
,
Message
public UUID getUuid()
AttributeReadUuid
UUID
of this object. When the object is created, a UUID
is generated. In case
the object is created from another object that already has a UUID
, the existing UUID
will be used (e.g. for chained exceptions
). UUID
will appear in a
stacktrace
but NOT
in the message
. It will therefore be written to
log-files if the NlsThrowable
is logged. If you supply the UUID
to
the end-user in an error panel or popup (see Message
), he can provide it with the
problem report so an administrator or software developer can easily find the stacktrace in the log-files.getUuid
in interface AttributeReadUuid
UUID
of this object. It may be null
if this feature is NOT supported by the type of
this object or turned of (it is turned on by default).public NlsMessage toNlsMessage()
NlsObject
Object.toString()
with native language support.toNlsMessage
in interface NlsObject
public String getInternationalizedMessage()
NlsMessage
root
locale
without resolving its NlsArgument
s.getInternationalizedMessage
in interface NlsMessage
"Welcome {name}!"
).NlsMessage
,
NlsMessage.getArgument(String)
,
MessageFormat
public int getArgumentCount()
NlsMessage
getArgumentCount
in interface NlsMessage
public Object getArgument(String key)
NlsMessage
key
.getArgument
in interface NlsMessage
key
- is the name of the requested argument.null
if NOT defined.NlsArgument
public Object getArgument(int index)
NlsMessage
index
.getArgument
in interface NlsMessage
index
- is the index of the requested argument.public boolean isTechnical()
NlsThrowable
displayed to the end-user
in such case. See
TechnicalErrorUserException
.message
is typically
intended for to end-users
and has to be easy to understand.NlsRuntimeException
.isTechnical
in interface NlsThrowable
true
if this is a technical exception, false
if this is a user error.NlsThrowable.isForUser()
public boolean isForUser()
isForUser
in interface NlsThrowable
true
if the message
of this exception is for end-users (or clients),
false
otherwise (for internal technical
errors).public NlsMessage getNlsMessage()
NlsThrowable
NlsMessage
describing the problem.getNlsMessage
in interface NlsThrowable
NlsMessage
.public String getLocalizedMessage(Locale locale)
NlsThrowable
getLocalizedMessage
in interface NlsThrowable
getLocalizedMessage
in interface NlsMessage
locale
- is the Locale
to translate to.NlsThrowable.getLocalizedMessage(Locale, Appendable)
public void getLocalizedMessage(Locale locale, Appendable appendable)
NlsThrowable
getLocalizedMessage
in interface NlsThrowable
getLocalizedMessage
in interface NlsMessage
locale
- is the Locale
to translate to.appendable
- is where to append
the message to.NlsMessage.getLocalizedMessage(Locale, Appendable)
public String getLocalizedMessage(Locale locale, NlsTemplateResolver resolver)
NlsMessage
getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.resolver
- is used to translate the message.NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver, Appendable)
public void getLocalizedMessage(Locale locale, NlsTemplateResolver resolver, Appendable buffer) throws IllegalStateException
NlsMessage
buffer
. template
that is provided via the given resolver
.
If this fails, the original message
will be used. After translation is done,
the language independent arguments will be filled in the translated message string according to the given
locale
.getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.resolver
- is used to resolve the template required to translate the internationalized message
.buffer
- is the buffer where to write the message to.IllegalStateException
public void printStackTrace(Locale locale, Appendable buffer) throws IllegalStateException
NlsThrowable
printStackTrace
in interface NlsThrowable
locale
- is the locale to translate to.buffer
- is where to write the stack trace to.IllegalStateException
- if the given buffer
produced an IOException
.public String toString()
NlsThrowable
toString
in interface NlsThrowable
toString
in class Throwable
NlsThrowable.toString(Locale)
public String toString(Locale locale)
NlsThrowable
NlsThrowable.toString()
but using the specified Locale
.toString
in interface NlsThrowable
locale
- is the Locale
used for NlsThrowable.getLocalizedMessage(Locale)
.NlsThrowable.toString(Locale, Appendable)
.public Appendable toString(Locale locale, Appendable appendable)
NlsThrowable
appends
the localized string representation of this exception. It is
defined as following:
<classname
>: [<custom-code
>: ]<message
>
toString
in interface NlsThrowable
locale
- is the Locale
used for NlsThrowable.getLocalizedMessage(Locale)
.appendable
- is the buffer to append
to. Will be created as
StringBuilder
if null
is provided.Appendable
or the created one if null
was given.Copyright © 2001–2016 mmm-Team. All rights reserved.