Package codes.thischwa.cf
Class CloudflareApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
codes.thischwa.cf.CloudflareApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CloudflareNotFoundException
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intValue ofgetStatusCode()if the exception was not caused by an HTTP response. -
Constructor Summary
ConstructorsConstructorDescriptionCloudflareApiException(String message) Constructs a new CloudflareApiException with the specified detail message.CloudflareApiException(String message, int statusCode, List<ResponseResultInfo.Error> errors) Constructs a new CloudflareApiException caused by an API response.CloudflareApiException(String message, Throwable cause) Constructs a new CloudflareApiException with the specified detail message and cause. -
Method Summary
Modifier and TypeMethodDescriptionReturns the errors reported by Cloudflare.intReturns the HTTP status code of the response that caused this exception.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
NO_STATUS_CODE
public static final int NO_STATUS_CODEValue ofgetStatusCode()if the exception was not caused by an HTTP response.- See Also:
-
-
Constructor Details
-
CloudflareApiException
Constructs a new CloudflareApiException with the specified detail message.- Parameters:
message- the detail message, which provides more information about the exception.
-
CloudflareApiException
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 messagestatusCode- the HTTP status code of the response, orNO_STATUS_CODEerrors- the errors reported by Cloudflare, may benull
-
-
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_CODEif the exception wasn't caused by an HTTP response
-
getErrors
Returns the errors reported by Cloudflare.- Returns:
- an unmodifiable list of errors, never
null
-