Enum Class EnduranceTrioError
- All Implemented Interfaces:
Serializable,Comparable<EnduranceTrioError>,Constable
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:
- Choose HTTP code that best matches the semantic (see IANA registry)
- Provide a generic, reusable message (specific context goes in
ErrorDTO) - Document when the error should be used (see examples above)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<EnduranceTrioError> fromCode(int code) Retrieves theEnduranceTrioErrorconstant corresponding to the given error code.intgetCode()static EnduranceTrioErrorReturns the enum constant of this class with the specified name.static EnduranceTrioError[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BAD_REQUEST
-
UNAUTHORIZED
-
FORBIDDEN
-
NOT_FOUND
-
CONFLICT
-
INTERNAL_ERROR
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
fromCode
Retrieves theEnduranceTrioErrorconstant corresponding to the given error code.- Parameters:
code- the error code- Returns:
- an
Optionalcontaining the matchingEnduranceTrioError, or empty if no match is found
-
getCode
public int getCode() -
getMessage
-