Enum Class HttpErrorCategory

java.lang.Object
java.lang.Enum<HttpErrorCategory>
de.cuioss.http.client.result.HttpErrorCategory
All Implemented Interfaces:
Serializable, Comparable<HttpErrorCategory>, Constable

Essential HTTP error codes for resilient operations. Provides minimal but sufficient error classification focused on actionable distinctions needed for retry logic, monitoring, and error handling.

Design Principles

  • Only includes error codes that require different handling
  • Focuses on operational concerns rather than detailed HTTP semantics
  • Enables effective retry and fallback strategies

Usage Pattern

 HttpResultObject<String> result = httpHandler.load();
 if (!result.isValid()) {
     result.getErrorCode().ifPresent(code -> {
         if (code.isRetryable()) {
             scheduleRetry();
         } else {
             useFallback();
         }
     });
 }
 
Since:
1.0
Author:
Implementation for HTTP operations
See Also:
  • Enum Constant Details

    • NETWORK_ERROR

      public static final HttpErrorCategory NETWORK_ERROR
      Network connectivity problems - timeouts, connection failures, etc. Covers all transient network issues that may resolve with retry.
    • SERVER_ERROR

      public static final HttpErrorCategory SERVER_ERROR
      Server-side errors (HTTP 5xx). Remote server problems that may be transient.
    • CLIENT_ERROR

      public static final HttpErrorCategory CLIENT_ERROR
      Client-side errors (HTTP 4xx). Request problems that typically require configuration changes.
    • INVALID_CONTENT

      public static final HttpErrorCategory INVALID_CONTENT
      Response content is invalid or unparseable. Covers all content validation failures including empty responses, malformed JSON, invalid JWKS, invalid well-known configs, etc.
    • CONFIGURATION_ERROR

      Configuration or setup errors. Invalid URLs, missing settings, SSL issues, authentication problems. Typically requires human intervention to resolve.
  • Method Details

    • values

      public static HttpErrorCategory[] 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 HttpErrorCategory 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
    • isRetryable

      public boolean isRetryable()
      Determines if this error code represents a retryable condition. Only network and server errors are typically transient and worth retrying.
      Returns:
      true if the error condition is typically retryable