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 FormModifier 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, setStackTrace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCause, getStackTrace
private 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()
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 final NlsMessage getNlsMessage()
NlsThrowable
NlsMessage
describing the problem.getNlsMessage
in interface NlsThrowable
NlsMessage
.public void printStackTrace(Locale locale, Appendable buffer)
NlsThrowable
printStackTrace
in interface NlsThrowable
locale
- 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()
AttributeReadMessage
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 AttributeReadMessage
getMessage
in class Throwable
Throwable.getMessage()
,
NlsThrowable
,
Message
public String getLocalizedMessage()
getLocalizedMessage
in class Throwable
public String getLocalizedMessage(Locale locale)
NlsThrowable
getLocalizedMessage
in interface NlsThrowable
locale
- is the Locale
to translate to.NlsThrowable.getLocalizedMessage(Locale, Appendable)
public void getLocalizedMessage(Locale locale, Appendable appendable)
NlsThrowable
getLocalizedMessage
in interface NlsThrowable
locale
- is the Locale
to translate to.appendable
- is where to append
the message to.NlsMessage.getLocalizedMessage(Locale, Appendable)
public NlsMessage toNlsMessage()
NlsObject
Object.toString()
with native language support.toNlsMessage
in interface NlsObject
protected 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()
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 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
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 NlsThrowable
truncation
- the ExceptionTruncation
to configure what to remove. E.g.
ExceptionTruncation.REMOVE_ALL
.exception
.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.