public abstract class NlsException extends Exception implements NlsThrowable, Cloneable
NlsRuntimeException instead.NlsThrowable,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private NlsMessage |
nlsMessage
the internationalized message
|
private static long |
serialVersionUID
UID for serialization.
|
private UUID |
uuid |
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 |
NlsException(NlsException copySource,
ExceptionTruncation truncation)
The copy constructor.
|
|
NlsException(NlsMessage message)
The constructor.
|
|
NlsException(Throwable nested,
NlsMessage message)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
NlsRuntimeException |
createCopy(ExceptionTruncation truncation)
Returns a copy of the given exception where the specified details are removed.
|
protected NlsRuntimeException |
createCopyViaClone(ExceptionTruncation truncation) |
protected UUID |
createUuid()
This method creates a new
UUID. |
String |
getCode()
This method gets the code that identifies the detailed type of this object.
|
String |
getLocalizedMessage() |
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 |
getMessage()
This method gets the actual message that describes this object.
|
NlsMessage |
getNlsMessage()
This method gets the
NlsMessage describing the problem. |
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, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTraceclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCause, getStackTraceprivate static final long serialVersionUID
private final NlsMessage nlsMessage
public NlsException(NlsMessage message)
message - the message describing the problem briefly.public NlsException(Throwable nested, NlsMessage message)
protected NlsException(NlsException copySource, ExceptionTruncation truncation)
copySource - is the exception to copy.truncation - is the ExceptionTruncation to configure potential truncations.protected UUID createUuid()
UUID.UUID or null to turn this feature off.public final 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 final NlsMessage getNlsMessage()
NlsMessage describing the problem.getNlsMessage in interface NlsThrowableNlsMessage.public void printStackTrace(Locale locale, Appendable buffer)
printStackTrace in interface NlsThrowablelocale - is the locale to translate to.buffer - is where to write the stack trace to.protected NlsRuntimeException createCopyViaClone(ExceptionTruncation truncation)
truncation - the ExceptionTruncation settings.createCopy(ExceptionTruncation)public NlsRuntimeException createCopy(ExceptionTruncation truncation)
ExceptionUtil
for advanced usage and further details. clone to create a
copy and truncate it as configured. However, a proper implementation would use the appropriate
copy constructor instead.createCopy in interface NlsThrowabletruncation - the ExceptionTruncation to configure what to remove. E.g.
ExceptionTruncation.REMOVE_ALL.exception.public String getMessage()
technical and should help operators or
developers to identify what happened or it will be information displayed to end-users and should be clear
and easy to understand. For internationalization see Message and
NlsMessage. In any case it should NOT contain sensitive information such
as passwords or (detailed) personal data.getMessage in interface AttributeReadMessagegetMessage in class ThrowableThrowable.getMessage(),
NlsThrowable,
Messagepublic String getLocalizedMessage()
getLocalizedMessage in class Throwablepublic String getLocalizedMessage(Locale locale)
getLocalizedMessage in interface NlsThrowablelocale - is the Locale to translate to.NlsThrowable.getLocalizedMessage(Locale, Appendable)public void getLocalizedMessage(Locale locale, Appendable appendable)
getLocalizedMessage in interface NlsThrowablelocale - is the Locale to translate to.appendable - is where to append the message to.NlsMessage.getLocalizedMessage(Locale, Appendable)public NlsMessage toNlsMessage()
Object.toString() with native language support.toNlsMessage in interface NlsObjectpublic 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 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 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.