Class ObjectNotFoundException

All Implemented Interfaces:
Localizable, LocalizableObject, Serializable

public class ObjectNotFoundException extends ApplicationException
An ObjectNotFoundException 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 return null or throw an ObjectNotFoundException.
Since:
1.0.0
See Also:
  • Field Details

  • Constructor Details

    • ObjectNotFoundException

      public ObjectNotFoundException(Object object)
      The constructor.
      Parameters:
      object - the 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 - the description (e.g. the classname) of the object that was required but could NOT be found.
      key - the key to the required object.
    • ObjectNotFoundException

      public ObjectNotFoundException(Object object, Object key, Throwable cause)
      The constructor.
      Parameters:
      object - the description (e.g. the classname) of the object that was required but could NOT be found.
      key - the key to the required object.
      cause - the cause of this exception.
    • ObjectNotFoundException

      public ObjectNotFoundException(Object object, Object key, Object options, Throwable cause)
      The constructor.
      Parameters:
      object - the description (e.g. the classname) of the object that was required but could NOT be found.
      key - the key to the required object.
      options - the available options (e.g. Collection of comma separated String of the available keys).
      cause - the cause of this exception.
    • ObjectNotFoundException

      protected ObjectNotFoundException(Localizable message, Throwable cause)
      The constructor.
      Parameters:
      message - the NLS message.
      cause - the cause of this exception. May be null.
  • Method Details

    • getCode

      public String getCode()
      Description copied from class: ApplicationException
      This method gets the code that identifies the detailed type of this object. While UUID is unique per instance of a ApplicationException this code is a short and readable identifier representing the ApplicationException Class. The default implementation returns the simple name. 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.
      Overrides:
      getCode in class ApplicationException
      Returns:
      the error code.