Class CloudflareApiException

java.lang.Object
java.lang.Throwable
java.lang.Exception
codes.thischwa.cf.CloudflareApiException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CloudflareNotFoundException

public class CloudflareApiException extends Exception
Represents a custom exception for errors encountered while interacting with the Cloudflare API.

If the error was caused by an API response, getStatusCode() returns the HTTP status code and getErrors() the errors reported by Cloudflare.

See Also:
  • Field Details

  • Constructor Details

    • CloudflareApiException

      public CloudflareApiException(String message)
      Constructs a new CloudflareApiException with the specified detail message.
      Parameters:
      message - the detail message, which provides more information about the exception.
    • CloudflareApiException

      public CloudflareApiException(String message, Throwable cause)
      Constructs a new CloudflareApiException with the specified detail message and cause.
      Parameters:
      message - the detail message, which provides additional context or information about the exception.
      cause - the cause of this exception, which is the underlying throwable that triggered this exception.
    • CloudflareApiException

      public CloudflareApiException(String message, int statusCode, List<ResponseResultInfo.Error> errors)
      Constructs a new CloudflareApiException caused by an API response.
      Parameters:
      message - the detail message
      statusCode - the HTTP status code of the response, or NO_STATUS_CODE
      errors - the errors reported by Cloudflare, may be null
  • Method Details

    • getStatusCode

      public int getStatusCode()
      Returns the HTTP status code of the response that caused this exception.
      Returns:
      the HTTP status code, or NO_STATUS_CODE if the exception wasn't caused by an HTTP response
    • getErrors

      public List<ResponseResultInfo.Error> getErrors()
      Returns the errors reported by Cloudflare.
      Returns:
      an unmodifiable list of errors, never null