Class SentinelApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
dev.demeng.sentinel.client.exception.SentinelException
dev.demeng.sentinel.client.exception.SentinelApiException
- All Implemented Interfaces:
Serializable
Thrown when the Sentinel API returns an error response (e.g. 401 Unauthorized, 429 Too Many
Requests, or 500 Internal Server Error).
Known 403 validation failures (e.g. expired or blacklisted license) are returned as a failed
ValidationResult rather than thrown.
Unrecognized 403 responses (e.g. permission denied due to a missing API key) are thrown as this
exception.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSentinelApiException(int httpStatus, @Nullable String type, String message) Creates a new API exception with no retry-after or cause.SentinelApiException(int httpStatus, @Nullable String type, String message, int retryAfterSeconds) Creates a new API exception with a retry-after value.SentinelApiException(int httpStatus, @Nullable String type, String message, int retryAfterSeconds, @Nullable Throwable cause) Creates a new API exception with all fields.SentinelApiException(int httpStatus, @Nullable String type, String message, @Nullable Throwable cause) Creates a new API exception with a cause. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
SentinelApiException
Creates a new API exception with no retry-after or cause.- Parameters:
httpStatus- the HTTP status codetype- the error type from the API responsemessage- the error message from the API response
-
SentinelApiException
public SentinelApiException(int httpStatus, @Nullable String type, String message, int retryAfterSeconds) Creates a new API exception with a retry-after value.- Parameters:
httpStatus- the HTTP status codetype- the error type from the API responsemessage- the error message from the API responseretryAfterSeconds- seconds to wait before retrying, or-1if not specified
-
SentinelApiException
public SentinelApiException(int httpStatus, @Nullable String type, String message, @Nullable Throwable cause) Creates a new API exception with a cause.- Parameters:
httpStatus- the HTTP status codetype- the error type from the API responsemessage- the error message from the API responsecause- the underlying exception
-
SentinelApiException
public SentinelApiException(int httpStatus, @Nullable String type, String message, int retryAfterSeconds, @Nullable Throwable cause) Creates a new API exception with all fields.- Parameters:
httpStatus- the HTTP status codetype- the error type from the API responsemessage- the error message from the API responseretryAfterSeconds- seconds to wait before retrying, or-1if not specifiedcause- the underlying exception, ornull
-
-
Method Details
-
getHttpStatus
public int getHttpStatus()Returns the HTTP status code of the error response.- Returns:
- the HTTP status code
-
getType
Returns the error type from the API response (e.g."UNAUTHORIZED").- Returns:
- the error type, or
null
-
getRetryAfterSeconds
public int getRetryAfterSeconds()Returns the number of seconds to wait before retrying, or-1if the server did not include a Retry-After header.- Returns:
- the retry-after value in seconds, or
-1
-