- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.github.mmm.base.exception.ApplicationException
-
- io.github.mmm.nls.exception.TechnicalErrorUserException
-
- All Implemented Interfaces:
Localizable
,LocalizableObject
,Serializable
public class TechnicalErrorUserException extends ApplicationException
ATechnicalErrorUserException
is wrapping an arbitrary technical error to a generic exception for end-users or clients. It helps to prevent "sensitive data exposure", an OWASP top ten security vulnerability.- Since:
- 1.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TechnicalErrorUserException(NlsMessage message, Throwable nested)
The constructor for the very special case that you want to define a custom message.TechnicalErrorUserException(Throwable cause)
The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ApplicationException
convert(Throwable exception)
String
getCode()
This method gets the code that identifies the detailed type of this object.boolean
isForUser()
Note: Please consider usingnet.sf.mmm.nls.exception.NlsException
with i18n support in case you are creating exceptions for end-users.boolean
isTechnical()
Determines if this is a technical exception.-
Methods inherited from class io.github.mmm.base.exception.ApplicationException
createUuid, getLocalizedMessage, getLocalizedMessage, getMessage, getNlsMessage, getNlsMessage, getUuid, printStackTrace, toString, toString, toString
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.base.i18n.Localizable
getArgument, getLocalizedMessage, toLocalizable
-
-
-
-
Field Detail
-
CODE
public static final String CODE
- See Also:
getCode()
, Constant Field Values
-
-
Constructor Detail
-
TechnicalErrorUserException
public TechnicalErrorUserException(Throwable cause)
The constructor.- Parameters:
cause
- is thecause
.
-
TechnicalErrorUserException
public TechnicalErrorUserException(NlsMessage message, Throwable nested)
The constructor for the very special case that you want to define a custom message. You are not encouraged to use this constructor. Please also consider that you can still customize the localized texts for the message when usingTechnicalErrorUserException(Throwable)
.
-
-
Method Detail
-
getCode
public final String getCode()
Description copied from class:ApplicationException
This method gets the code that identifies the detailed type of this object. WhileUUID
is unique per instance of aApplicationException
this code is a short and readable identifier representing theApplicationException
Class
. The default implementation returns thesimple name
. However, the code should remain stable after refactoring (so at least after the rename the previous code should be returned asString
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.- Overrides:
getCode
in classApplicationException
- Returns:
- the error code.
-
isTechnical
public final boolean isTechnical()
Description copied from class:ApplicationException
Determines if this is a technical exception.- A technical exception is an unexpected situation that is to be logged on error level and should be analyzed by
the operators or software developers of the system. Further in such case the end-user can typically do nothing
about the problem (except to retry his operation) and will typically not understand the problem. Therefore a
generic message should be
displayed to the end-user
in such case. - A non technical exception is called user failure. It is an undesired but NOT abnormal situation (e.g.
a mandatory field was not filled). It should be logged on a level less than error (typically info). The
message
is typicallyintended for to end-users
and has to be easy to understand.
- Overrides:
isTechnical
in classApplicationException
- Returns:
true
if this is a technical exception,false
if this is a user error.- See Also:
ApplicationException.isForUser()
- A technical exception is an unexpected situation that is to be logged on error level and should be analyzed by
the operators or software developers of the system. Further in such case the end-user can typically do nothing
about the problem (except to retry his operation) and will typically not understand the problem. Therefore a
generic message should be
-
isForUser
public final boolean isForUser()
Description copied from class:ApplicationException
Note: Please consider usingnet.sf.mmm.nls.exception.NlsException
with i18n support in case you are creating exceptions for end-users.- Overrides:
isForUser
in classApplicationException
- Returns:
true
if themessage
of this exception is for end-users (or clients),false
otherwise (for internaltechnical
errors).
-
convert
public static ApplicationException convert(Throwable exception)
- Parameters:
exception
- is theThrowable
to convert.- Returns:
- the
ApplicationException
withisForUser()
returningtrue
.
-
-