Class CheckHimException

java.lang.Object
java.lang.Throwable
java.lang.Exception
tech.checkhim.exceptions.CheckHimException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InvalidFormatException, NetworkRejectedException, PrefixMissingException, SubscriberAbsentException, UnknownSubscriberException

public class CheckHimException extends Exception
Base exception class for all CheckHim SDK related errors. This exception is thrown when any error occurs during API communication or processing of verification requests.
See Also:
  • Constructor Details

    • CheckHimException

      public CheckHimException(String message)
      Creates a new CheckHimException with the specified message.
      Parameters:
      message - The error message
    • CheckHimException

      public CheckHimException(String message, Throwable cause)
      Creates a new CheckHimException with the specified message and cause.
      Parameters:
      message - The error message
      cause - The underlying cause
    • CheckHimException

      public CheckHimException(String message, String errorCode, int httpStatusCode)
      Creates a new CheckHimException with detailed error information.
      Parameters:
      message - The error message
      errorCode - The CheckHim error code
      httpStatusCode - The HTTP status code from the API response
    • CheckHimException

      public CheckHimException(String message, String errorCode, int httpStatusCode, Throwable cause)
      Creates a new CheckHimException with detailed error information and cause.
      Parameters:
      message - The error message
      errorCode - The CheckHim error code
      httpStatusCode - The HTTP status code from the API response
      cause - The underlying cause
  • Method Details

    • getErrorCode

      public String getErrorCode()
      Gets the CheckHim-specific error code.
      Returns:
      The error code (e.g., "REJECTED_NETWORK"), or null if not available
    • getHttpStatusCode

      public int getHttpStatusCode()
      Gets the HTTP status code from the API response.
      Returns:
      The HTTP status code, or 0 if not available
    • isClientError

      public boolean isClientError()
      Checks if this exception represents a client error (4xx status code).
      Returns:
      true if the HTTP status code is in the 4xx range
    • isServerError

      public boolean isServerError()
      Checks if this exception represents a server error (5xx status code).
      Returns:
      true if the HTTP status code is in the 5xx range
    • toString

      public String toString()
      Overrides:
      toString in class Throwable