- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.github.mmm.base.exception.ApplicationException
-
- io.github.mmm.base.exception.ObjectNotFoundException
-
- All Implemented Interfaces:
Localizable
,LocalizableObject
,Serializable
- Direct Known Subclasses:
ObjectNotFoundUserException
public class ObjectNotFoundException extends ApplicationException
AnObjectNotFoundException
is thrown if an object was requested but does not exist or could not be found.
This typically happens in situations where required objects are requested by a key (e.g. in a registry-Map
) but an expected object was not registered or the key is wrong for some reason.
If you design your API consider carefully if you should returnnull
or throw anObjectNotFoundException
.- Since:
- 1.0.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
MESSAGE_CODE
-
Constructor Summary
Constructors Modifier Constructor Description protected
ObjectNotFoundException(Localizable message, Throwable cause)
The constructor.ObjectNotFoundException(Object object)
The constructor.ObjectNotFoundException(Object object, Object key)
The constructor.ObjectNotFoundException(Object object, Object key, Throwable cause)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCode()
This method gets the code that identifies the detailed type of this object.-
Methods inherited from class io.github.mmm.base.exception.ApplicationException
createUuid, getLocalizedMessage, getLocalizedMessage, getMessage, getNlsMessage, getNlsMessage, getUuid, isForUser, isTechnical, 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
-
MESSAGE_CODE
public static final String MESSAGE_CODE
- See Also:
getCode()
, Constant Field Values
-
-
Constructor Detail
-
ObjectNotFoundException
public ObjectNotFoundException(Object object)
The constructor.- Parameters:
object
- is a description (e.g. the classname) of the object that was required but could not be found.
-
ObjectNotFoundException
public ObjectNotFoundException(Object object, Object key)
The constructor.- Parameters:
object
- is a description (e.g. the classname) of the object that was required but could not be found.key
- is the key to the required object.
-
ObjectNotFoundException
public ObjectNotFoundException(Object object, Object key, Throwable cause)
The constructor.- Parameters:
object
- is a description (e.g. the classname) of the object that was required but could NOT be found.key
- is the key to the required object.cause
- is thecause
of this exception.
-
ObjectNotFoundException
protected ObjectNotFoundException(Localizable message, Throwable cause)
The constructor.- Parameters:
message
- theNLS message
.cause
- is thecause
of this exception. May benull
.
-
-
Method Detail
-
getCode
public 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.
-
-