public class ApiErrorExtractor
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCESS_NOT_CONFIGURED_REASON_CODE |
static java.lang.String |
ACCOUNT_DISABLED_REASON_CODE |
static java.lang.String |
FIELD_SIZE_TOO_LARGE |
static java.lang.String |
GLOBAL_DOMAIN |
static ApiErrorExtractor |
INSTANCE
Singleton instance of the ApiErrorExtractor.
|
static java.lang.String |
RATE_LIMITED_REASON_CODE |
static java.lang.String |
RESOURCE_NOT_READY_REASON_CODE |
static int |
STATUS_CODE_CONFLICT |
static int |
STATUS_CODE_PRECONDITION_FAILED |
static int |
STATUS_CODE_RANGE_NOT_SATISFIABLE |
static java.lang.String |
USAGE_LIMITS_DOMAIN |
static java.lang.String |
USER_PROJECT_MISSING |
static java.lang.String |
USER_RATE_LIMITED_REASON_CODE |
Constructor and Description |
---|
ApiErrorExtractor()
Deprecated.
use
INSTANCE instead |
Modifier and Type | Method and Description |
---|---|
boolean |
accessDenied(java.io.IOException e)
Determines if the given exception indicates 'access denied'.
|
boolean |
accessDeniedNonRecoverable(com.google.api.client.googleapis.json.GoogleJsonError e)
Determine if a given GoogleJsonError is caused by, and only by,
account disabled error.
|
boolean |
accessDeniedNonRecoverable(java.io.IOException e)
Determine if the exception is a non-recoverable access denied code
(such as account closed or marked for deletion).
|
boolean |
fieldSizeTooLarge(com.google.api.client.googleapis.json.GoogleJsonError e)
Determines if the given GoogleJsonError indicates 'field size too large'.
|
boolean |
fieldSizeTooLarge(java.io.IOException e)
Determines if the given exception indicates 'field size too large'.
|
java.lang.String |
getDebugInfo(java.io.IOException ioe) |
protected com.google.api.client.googleapis.json.GoogleJsonError |
getDetails(java.io.IOException e)
If the exception is a GoogleJsonResponseException, get the error details, else return null.
|
protected com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo |
getErrorInfo(com.google.api.client.googleapis.json.GoogleJsonError details)
Get the first ErrorInfo from a GoogleJsonError, or null if there is not one.
|
protected com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo |
getErrorInfo(java.io.IOException e)
Get the first ErrorInfo from an IOException if it is an instance of
GoogleJsonResponseException, otherwise return null.
|
java.lang.String |
getErrorMessage(java.io.IOException e)
Extracts the error message.
|
protected int |
getHttpStatusCode(com.google.api.client.googleapis.json.GoogleJsonResponseException e)
Returns HTTP status code from the given exception.
|
static com.google.api.client.googleapis.json.GoogleJsonResponseException |
getJsonResponseExceptionOrNull(java.lang.Throwable t) |
boolean |
ioError(java.lang.Throwable throwable)
Determine if a given Throwable is caused by an IO error.
|
boolean |
isClientError(java.io.IOException e)
Determines if the exception is a client error.
|
boolean |
isInternalServerError(java.io.IOException e)
Determines if the exception is an internal server error.
|
boolean |
itemAlreadyExists(java.io.IOException e)
Determines if the given exception indicates 'item already exists'.
|
boolean |
itemNotFound(com.google.api.client.googleapis.json.GoogleJsonError e)
Determines if the given GoogleJsonError indicates 'item not found'.
|
boolean |
itemNotFound(java.io.IOException e)
Determines if the given exception indicates 'item not found'.
|
boolean |
preconditionNotMet(com.google.api.client.googleapis.json.GoogleJsonError e)
Determines if the given GoogleJsonError indicates 'precondition not met'
|
boolean |
preconditionNotMet(java.io.IOException e)
Determine if the given IOException indicates 'precondition not met'
Recursively checks getCause() if outer exception isn't
an instance of the correct class.
|
boolean |
rangeNotSatisfiable(java.io.IOException e)
Determines if the given exception indicates 'range not satisfiable'.
|
boolean |
rateLimited(com.google.api.client.googleapis.json.GoogleJsonError e)
Determine if a given GoogleJsonError is caused by, and only by,
a rate limit being applied.
|
boolean |
rateLimited(java.lang.Throwable throwable)
Determine if a given Throwable is caused by a rate limit being applied.
|
boolean |
readTimedOut(java.io.IOException ex)
True if the exception is a "read timed out".
|
protected boolean |
recursiveCheckForCode(java.lang.Throwable e,
int code)
Recursively checks getCause() if outer exception isn't an instance of the correct class.
|
boolean |
resourceNotReady(com.google.api.client.googleapis.json.GoogleJsonError e)
Determines if the given GoogleJsonError indicates 'resource not ready'.
|
boolean |
resourceNotReady(java.io.IOException e)
Determines if the given exception indicates 'resource not ready'.
|
boolean |
socketError(java.lang.Throwable throwable)
Determine if a given Throwable is caused by a socket error.
|
java.io.IOException |
toUserPresentableException(java.io.IOException ioe,
java.lang.String action)
Converts the exception to a user-presentable error message.
|
java.lang.String |
toUserPresentableMessage(java.io.IOException ioe) |
java.lang.String |
toUserPresentableMessage(java.io.IOException ioe,
java.lang.String action)
Converts the exception to a user-presentable error message.
|
boolean |
unauthorized(java.io.IOException e)
Determine if the given exception indicates the request was unauthenticated.
|
boolean |
userProjectMissing(com.google.api.client.googleapis.json.GoogleJsonError e)
Determines if the given GoogleJsonError indicates that 'userProject' is missing in request
|
boolean |
userProjectMissing(java.io.IOException e)
Determines if the given exception indicates that 'userProject' is missing in request.
|
public static final ApiErrorExtractor INSTANCE
public static final int STATUS_CODE_CONFLICT
public static final int STATUS_CODE_PRECONDITION_FAILED
public static final int STATUS_CODE_RANGE_NOT_SATISFIABLE
public static final java.lang.String GLOBAL_DOMAIN
public static final java.lang.String USAGE_LIMITS_DOMAIN
public static final java.lang.String RATE_LIMITED_REASON_CODE
public static final java.lang.String USER_RATE_LIMITED_REASON_CODE
public static final java.lang.String ACCOUNT_DISABLED_REASON_CODE
public static final java.lang.String ACCESS_NOT_CONFIGURED_REASON_CODE
public static final java.lang.String RESOURCE_NOT_READY_REASON_CODE
public static final java.lang.String FIELD_SIZE_TOO_LARGE
public static final java.lang.String USER_PROJECT_MISSING
@Deprecated public ApiErrorExtractor()
INSTANCE
insteadpublic boolean accessDenied(java.io.IOException e)
Warning: this method only checks for access denied status code,
however this may include potentially recoverable reason codes such as
rate limiting. For alternative, see
accessDeniedNonRecoverable(IOException)
.
public boolean unauthorized(java.io.IOException e)
public boolean accessDeniedNonRecoverable(java.io.IOException e)
public boolean accessDeniedNonRecoverable(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean isClientError(java.io.IOException e)
public boolean isInternalServerError(java.io.IOException e)
public boolean itemAlreadyExists(java.io.IOException e)
public boolean itemNotFound(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean itemNotFound(java.io.IOException e)
public boolean fieldSizeTooLarge(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean fieldSizeTooLarge(java.io.IOException e)
public boolean resourceNotReady(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean resourceNotReady(java.io.IOException e)
public boolean preconditionNotMet(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean preconditionNotMet(java.io.IOException e)
public boolean rangeNotSatisfiable(java.io.IOException e)
public boolean rateLimited(com.google.api.client.googleapis.json.GoogleJsonError e)
e
- The GoogleJsonError returned by the requestpublic boolean rateLimited(java.lang.Throwable throwable)
throwable
- The Throwable to check.public boolean userProjectMissing(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean userProjectMissing(java.io.IOException e)
public boolean ioError(java.lang.Throwable throwable)
throwable
- The Throwable to check.public boolean socketError(java.lang.Throwable throwable)
throwable
- The Throwable to check.public boolean readTimedOut(java.io.IOException ex)
public java.lang.String getErrorMessage(java.io.IOException e)
public java.io.IOException toUserPresentableException(java.io.IOException ioe, java.lang.String action) throws java.io.IOException
ioe
- the exceptionaction
- the description of the action being performed at the time of error.java.io.IOException
toUserPresentableMessage(IOException, String)
public java.lang.String toUserPresentableMessage(java.io.IOException ioe, @Nullable java.lang.String action)
public java.lang.String toUserPresentableMessage(java.io.IOException ioe)
@Nullable public java.lang.String getDebugInfo(java.io.IOException ioe)
protected int getHttpStatusCode(com.google.api.client.googleapis.json.GoogleJsonResponseException e)
Note: GoogleJsonResponseException.getStatusCode() method is marked final therefore it cannot be mocked using Mockito. We use this helper so that we can override it in tests.
protected com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo getErrorInfo(java.io.IOException e)
protected com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo getErrorInfo(com.google.api.client.googleapis.json.GoogleJsonError details)
protected com.google.api.client.googleapis.json.GoogleJsonError getDetails(java.io.IOException e)
protected boolean recursiveCheckForCode(java.lang.Throwable e, int code)
@Nullable public static com.google.api.client.googleapis.json.GoogleJsonResponseException getJsonResponseExceptionOrNull(java.lang.Throwable t)
Copyright © 2019. All rights reserved.