public abstract class NlsRuntimeException extends RuntimeException implements NlsThrowable, Cloneable
NlsThrowable based on RuntimeException. For further
details see NlsThrowable. For an example read the package javadoc or
see the source code of the derived exceptions.NlsThrowable,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private NlsMessage |
nlsMessage
the internationalized message
|
private static long |
serialVersionUID |
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 |
NlsRuntimeException()
The constructor for de-serialization in GWT.
|
|
NlsRuntimeException(NlsMessage message)
The constructor.
|
protected |
NlsRuntimeException(NlsRuntimeException copySource,
ExceptionTruncation truncation)
The copy constructor.
|
|
NlsRuntimeException(String internationalizedMessage)
The constructor.
|
|
NlsRuntimeException(Throwable cause,
NlsMessage message)
The constructor.
|
|
NlsRuntimeException(Throwable cause,
String internationalizedMessage)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static <BUNDLE extends NlsBundle> |
createBundle(Class<BUNDLE> bundleInterface) |
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).
|
(package private) static void |
printStackTrace(NlsThrowable throwable,
Locale locale,
Appendable buffer) |
private static void |
printStackTraceCause(Throwable cause,
Locale locale,
Appendable buffer) |
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 NlsMessage nlsMessage
private UUID uuid
protected NlsRuntimeException()
public NlsRuntimeException(NlsMessage message)
message - the message describing the problem briefly.public NlsRuntimeException(String internationalizedMessage)
NlsRuntimeException(NlsMessage) in advance to this constructor to get best
NLS/I18N.internationalizedMessage - is a short description of the problem. It is used for
internationalization and should be in English language.public NlsRuntimeException(Throwable cause, String internationalizedMessage)
NlsRuntimeException(Throwable, NlsMessage) in advance to this constructor to
get best NLS/I18N.cause - is the cause of this exception.internationalizedMessage - is a short description of the problem. It is used for
internationalization and should be in English language.public NlsRuntimeException(Throwable cause, NlsMessage message)
protected NlsRuntimeException(NlsRuntimeException 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()
AttributeReadUuidUUID 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()
NlsThrowableNlsMessage describing the problem.getNlsMessage in interface NlsThrowableNlsMessage.public void printStackTrace(Locale locale, Appendable buffer)
NlsThrowableprintStackTrace in interface NlsThrowablelocale - is the locale to translate to.buffer - is where to write the stack trace to.static void printStackTrace(NlsThrowable throwable, Locale locale, Appendable buffer)
throwable - is the NlsThrowable to print.locale - is the Locale to translate to.buffer - is where to write the stack trace to.NlsThrowable.printStackTrace(Locale, Appendable)private static void printStackTraceCause(Throwable cause, Locale locale, Appendable buffer) throws IOException
cause - is the Throwable to print.locale - is the Locale to translate to.buffer - is where to write the stack trace to.IOException - if caused by buffer.NlsThrowable.printStackTrace(Locale, Appendable)public String getMessage()
AttributeReadMessagetechnical 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)
NlsThrowablegetLocalizedMessage in interface NlsThrowablelocale - is the Locale to translate to.NlsThrowable.getLocalizedMessage(Locale, Appendable)public void getLocalizedMessage(Locale locale, Appendable appendable)
NlsThrowablegetLocalizedMessage in interface NlsThrowablelocale - is the Locale to translate to.appendable - is where to append the message to.NlsMessage.getLocalizedMessage(Locale, Appendable)public NlsMessage toNlsMessage()
NlsObjectObject.toString() with native language support.toNlsMessage in interface NlsObjectprotected static <BUNDLE extends NlsBundle> BUNDLE createBundle(Class<BUNDLE> bundleInterface)
BUNDLE - is the generic type of the requested NlsBundle.bundleInterface - is the NlsBundle interface.NlsBundle instance.NlsBundleFactory.createBundle(Class)public boolean isTechnical()
NlsThrowabledisplayed 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()
AttributeReadMessageCodeUUID 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,
Messageprotected 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 toString()
NlsThrowabletoString in interface NlsThrowabletoString in class ThrowableNlsThrowable.toString(Locale)public String toString(Locale locale)
NlsThrowableNlsThrowable.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)
NlsThrowableappends 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–2016 mmm-Team. All rights reserved.