Enum Class EnduranceTrioError

java.lang.Object
java.lang.Enum<EnduranceTrioError>
com.endurancetrio.business.common.exception.EnduranceTrioError
All Implemented Interfaces:
Serializable, Comparable<EnduranceTrioError>, Constable

public enum EnduranceTrioError extends Enum<EnduranceTrioError>
The EnduranceTrioError enum defines standardized error codes and messages for the EnduranceTrio project. Each constant represents a specific failure category aligned with HTTP status codes.

Design Rationale

Error codes are intentionally coupled to HTTP status codes because:

  • This is a REST API—HTTP codes provide universal client semantics
  • Clients can branch on status ranges (4xx = client error, 5xx = server error)
  • Standard codes reduce API documentation burden

Adding New Errors

When adding constants:

  1. Choose HTTP code that best matches the semantic (see IANA registry)
  2. Provide a generic, reusable message (specific context goes in ErrorDTO)
  3. Document when the error should be used (see examples above)
Reference: IANA HTTP Status Codes
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static EnduranceTrioError[] 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 EnduranceTrioError 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
    • fromCode

      public static Optional<EnduranceTrioError> fromCode(int code)
      Retrieves the EnduranceTrioError constant corresponding to the given error code.
      Parameters:
      code - the error code
      Returns:
      an Optional containing the matching EnduranceTrioError, or empty if no match is found
    • getCode

      public int getCode()
    • getMessage

      public String getMessage()