Enum Class ErrorKind

java.lang.Object
java.lang.Enum<ErrorKind>
is.codion.framework.json.db.ErrorKind
All Implemented Interfaces:
Serializable, Comparable<ErrorKind>, Constable

public enum ErrorKind extends Enum<ErrorKind>
The kind of error an ErrorEnvelope carries, a closed set.

Each kind determines the HTTP status of the error response and the severity at which the server logs it, and it is the only type information crossing the wire, the client mapping it to a known exception constructor. A class name plus reflective instantiation would reintroduce the arbitrary-instantiation problem the envelope exists to remove, so an unrecognized kind, which a client older than the server encounters, must be treated as a generic error rather than resolved.

See Also:
  • Enum Constant Details

    • AUTHENTICATION

      public static final ErrorKind AUTHENTICATION
      Authentication failed, or the credentials, client id or client type headers are missing or malformed.
    • BAD_REQUEST

      public static final ErrorKind BAD_REQUEST
      The request is malformed, an unparseable body, an unknown entity type or attribute name, a malformed header.
    • ILLEGAL_STATE

      public static final ErrorKind ILLEGAL_STATE
      The request is at odds with the state of the connection, committing when no transaction is open, or with the state of the domain, calling an operation whose parameter type is not registered.

      Logged at ErrorKind.Severity.WARN, being a programming error on one side or the other, and reported as IllegalStateException, which EntityConnection's transaction methods document.

    • CONNECTION_UNAVAILABLE

      public static final ErrorKind CONNECTION_UNAVAILABLE
      The server is at its connection limit.
    • CONFLICT_MODIFIED

      public static final ErrorKind CONFLICT_MODIFIED
      An entity being updated has been modified or deleted since it was loaded.
    • CONFLICT_REFERENTIAL

      public static final ErrorKind CONFLICT_REFERENTIAL
      A referential integrity constraint prevented the operation.
    • CONFLICT_UNIQUE

      public static final ErrorKind CONFLICT_UNIQUE
      A unique constraint prevented the operation.
    • NOT_FOUND

      public static final ErrorKind NOT_FOUND
      An expected entity was not found.
    • MULTIPLE_FOUND

      public static final ErrorKind MULTIPLE_FOUND
      One entity was expected but many were found.
    • INSERT

      public static final ErrorKind INSERT
      An insert failed.
    • UPDATE

      public static final ErrorKind UPDATE
      An update failed.
    • DELETE

      public static final ErrorKind DELETE
      A delete failed.
    • QUERY_TIMEOUT

      public static final ErrorKind QUERY_TIMEOUT
      A statement timed out or was cancelled.
    • REPORT

      public static final ErrorKind REPORT
      A report failed to fill or export.

      The message is passed verbatim, unlike INTERNAL, the plugin producing it having already stripped any reporting engine type, so a client without the engine reconstructs the failure as a ReportException, which lives in common-db. A serial client receives that same exception directly, so the message reaches both.

      Logged at ErrorKind.Severity.ERROR, a report failure being a data or deployment fault, a missing exporter extension for one.

    • DATABASE

      public static final ErrorKind DATABASE
      A database error with no more specific kind.
    • INTERNAL

      public static final ErrorKind INTERNAL
      Anything else, the server is at fault. The message is replaced with a generic one, the ErrorEnvelope.correlationId() being the client's only link to the server log.
  • Method Details

    • values

      public static ErrorKind[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ErrorKind valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • status

      public int status()
      Returns:
      the HTTP status of an error response of this kind
    • severity

      public ErrorKind.Severity severity()
      Returns:
      the severity at which the server logs an error of this kind
    • of

      public static Optional<ErrorKind> of(String name)
      Returns the ErrorKind with the given name, an empty Optional if none exists, which is how a client older than the server encounters a kind it does not know.
      Parameters:
      name - the kind name
      Returns:
      the ErrorKind with the given name