public class ApiErrorExtractor extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ACCESS_NOT_CONFIGURED_REASON_CODE |
static String |
ACCOUNT_DISABLED_REASON_CODE |
static String |
FIELD_SIZE_TOO_LARGE |
static String |
GLOBAL_DOMAIN |
static String |
RATE_LIMITED_REASON_CODE |
static 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 String |
USAGE_LIMITS_DOMAIN |
static String |
USER_RATE_LIMITED_REASON_CODE |
| Constructor and Description |
|---|
ApiErrorExtractor() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accessDenied(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(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(IOException e)
Determines if the given exception indicates 'field size too large'.
|
protected com.google.api.client.googleapis.json.GoogleJsonError |
getDetails(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(IOException e)
Get the first ErrorInfo from an IOException if it is an instance of
GoogleJsonResponseException, otherwise return null.
|
String |
getErrorMessage(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.
|
boolean |
ioError(Throwable throwable)
Determine if a given Throwable is caused by an IO error.
|
boolean |
isClientError(IOException e)
Determines if the exception is a client error.
|
boolean |
isInternalServerError(IOException e)
Determines if the exception is an internal server error.
|
boolean |
itemAlreadyExists(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(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(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(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(Throwable throwable)
Determine if a given Throwable is caused by a rate limit being applied.
|
boolean |
readTimedOut(IOException ex)
True if the exception is a "read timed out".
|
protected boolean |
recursiveCheckForCode(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(IOException e)
Determines if the given exception indicates 'resource not ready'.
|
boolean |
socketError(Throwable throwable)
Determine if a given Throwable is caused by a socket error.
|
IOException |
toUserPresentableException(IOException ioe,
String action)
Converts the exception to a user-presentable error message.
|
String |
toUserPresentableMessage(IOException ioe) |
String |
toUserPresentableMessage(IOException ioe,
String action)
Converts the exception to a user-presentable error message.
|
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 String GLOBAL_DOMAIN
public static final String USAGE_LIMITS_DOMAIN
public static final String RATE_LIMITED_REASON_CODE
public static final String USER_RATE_LIMITED_REASON_CODE
public static final String ACCOUNT_DISABLED_REASON_CODE
public static final String ACCESS_NOT_CONFIGURED_REASON_CODE
public static final String RESOURCE_NOT_READY_REASON_CODE
public static final String FIELD_SIZE_TOO_LARGE
public boolean accessDenied(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 accessDeniedNonRecoverable(IOException e)
public boolean accessDeniedNonRecoverable(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean isClientError(IOException e)
public boolean isInternalServerError(IOException e)
public boolean itemAlreadyExists(IOException e)
public boolean itemNotFound(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean itemNotFound(IOException e)
public boolean fieldSizeTooLarge(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean fieldSizeTooLarge(IOException e)
public boolean resourceNotReady(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean resourceNotReady(IOException e)
public boolean preconditionNotMet(com.google.api.client.googleapis.json.GoogleJsonError e)
public boolean preconditionNotMet(IOException e)
public boolean rangeNotSatisfiable(IOException e)
public boolean rateLimited(com.google.api.client.googleapis.json.GoogleJsonError e)
e - The GoogleJsonError returned by the requestpublic boolean rateLimited(Throwable throwable)
throwable - The Throwable to check.public boolean ioError(Throwable throwable)
throwable - The Throwable to check.public boolean socketError(Throwable throwable)
throwable - The Throwable to check.public boolean readTimedOut(IOException ex)
public String getErrorMessage(IOException e)
public IOException toUserPresentableException(IOException ioe, String action) throws IOException
ioe - the exceptionaction - the description of the action being performed at the time of error.IOExceptiontoUserPresentableMessage(IOException, String)public String toUserPresentableMessage(IOException ioe, @Nullable String action)
public String toUserPresentableMessage(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(IOException e)
protected com.google.api.client.googleapis.json.GoogleJsonError getDetails(IOException e)
protected com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo getErrorInfo(com.google.api.client.googleapis.json.GoogleJsonError details)
protected boolean recursiveCheckForCode(Throwable e, int code)
Copyright © 2016. All rights reserved.