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
causes 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
UID for serialization.
|
private boolean |
technical |
private UUID |
uuid |
LOCALIZATION_FAILURE_PREFIXKEY_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 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 that can be
translated to a native language. |
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, setStackTraceclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCause, getStackTracegetMessagegetLocalizedMessage, getMessageprivate static final long serialVersionUID
private String originalExceptionName
getOriginalExceptionName()private boolean technical
isTechnical()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)
ExceptionUtil
for advanced usage and further details. createCopy in interface NlsThrowabletruncation - the ExceptionTruncation to configure what to remove. E.g.
ExceptionTruncation.REMOVE_ALL.exception.public String getOriginalExceptionName()
public Throwable fillInStackTrace()
fillInStackTrace in class Throwablepublic String getCode()
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 AttributeReadMessageCodeThrowable.getMessage(),
NlsThrowable,
Messagepublic UUID getUuid()
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 AttributeReadUuidUUID 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()
Object.toString() with native language support.toNlsMessage in interface NlsObjectpublic String getInternationalizedMessage()
translated to a native language. The language
independent arguments are filled into the message after the translation process. "Welcome {name}!" and there is one argument that is the string
"Joelle". The final result will then be "Welcome Joelle!". If the message is
translated to German as "Willkommen {name}!" the final result will be
"Willkommen Joelle!".getInternationalizedMessage in interface NlsMessageNlsMessage,
NlsMessage.getArgument(String),
MessageFormatpublic int getArgumentCount()
getArgumentCount in interface NlsMessagepublic Object getArgument(String key)
key.getArgument in interface NlsMessagekey - is the name of the requested argument.null if NOT defined.public Object getArgument(int index)
index.getArgument in interface NlsMessageindex - is the index of the requested argument.public boolean isTechnical()
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 NlsThrowabletrue if this is a technical exception, false if this is a user error.NlsThrowable.isForUser()public boolean isForUser()
isForUser in interface NlsThrowabletrue if the message of this exception is for end-users (or
clients), false otherwise (for internal technical errors).public NlsMessage getNlsMessage()
NlsMessage describing the problem.getNlsMessage in interface NlsThrowableNlsMessage.public String getLocalizedMessage(Locale locale)
getLocalizedMessage in interface NlsThrowablegetLocalizedMessage in interface NlsMessagelocale - is the Locale to translate to.NlsThrowable.getLocalizedMessage(Locale, Appendable)public void getLocalizedMessage(Locale locale, Appendable appendable)
getLocalizedMessage in interface NlsThrowablegetLocalizedMessage in interface NlsMessagelocale - 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)
getLocalizedMessage in interface NlsMessagelocale - 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
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 NlsMessagelocale - 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.IllegalStateExceptionpublic void printStackTrace(Locale locale, Appendable buffer) throws IllegalStateException
printStackTrace in interface NlsThrowablelocale - 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()
toString in interface NlsThrowabletoString in class ThrowableNlsThrowable.toString(Locale)public String toString(Locale locale)
NlsThrowable.toString() but using the specified Locale.toString in interface NlsThrowablelocale - is the Locale used for NlsThrowable.getLocalizedMessage(Locale).NlsThrowable.toString(Locale, Appendable).public Appendable toString(Locale locale, Appendable appendable)
appends the localized string representation of this exception. It
is defined as following:
<classname>: [<custom-code>: ]<message>
toString in interface NlsThrowablelocale - 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–2015 mmm-Team. All rights reserved.