public static boolean isFileNotFoundException(StorageException e) { String errorCode = e.getErrorCode(); if (errorCode != null && (errorCode.equals(StorageErrorCodeStrings.BLOB_NOT_FOUND) || errorCode.equals(StorageErrorCodeStrings.RESOURCE_NOT_FOUND) || errorCode.equals(StorageErrorCodeStrings.CONTAINER_NOT_FOUND) || errorCode.equals(StorageErrorCode.BLOB_NOT_FOUND.toString()) || errorCode.equals(StorageErrorCode.RESOURCE_NOT_FOUND.toString()) || errorCode.equals(StorageErrorCode.CONTAINER_NOT_FOUND.toString()))) { return true; } return false; }
switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: errorCode = StorageErrorCode.ACCESS_DENIED.toString(); break; case HttpURLConnection.HTTP_GONE: case HttpURLConnection.HTTP_NOT_FOUND: errorCode = StorageErrorCode.RESOURCE_NOT_FOUND.toString(); break; case 416: case HttpURLConnection.HTTP_BAD_REQUEST: errorCode = StorageErrorCode.BAD_REQUEST.toString(); break; errorCode = StorageErrorCode.CONDITION_FAILED.toString(); break; errorCode = StorageErrorCode.RESOURCE_ALREADY_EXISTS.toString(); break; errorCode = StorageErrorCode.SERVER_BUSY.toString(); break; errorCode = StorageErrorCode.SERVICE_TIMEOUT.toString(); break; errorCode = StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(); break;
/** * Returns an unexpected storage exception. * * @param cause * An <code>Exception</code> object that represents the initial exception that caused the unexpected * error. * * @return A {@link StorageException} object that represents the unexpected storage exception being thrown. */ public static StorageException generateNewUnexpectedStorageException(final Exception cause) { final StorageException exceptionRef = new StorageException(StorageErrorCode.NONE.toString(), "Unexpected internal storage client error.", 306, // unused null, null); exceptionRef.initCause(cause); return exceptionRef; }
/** * Returns an unexpected storage exception. * * @param cause * An <code>Exception</code> object that represents the initial exception that caused the unexpected * error. * * @return A {@link StorageException} object that represents the unexpected storage exception being thrown. */ public static StorageException generateNewUnexpectedStorageException(final Exception cause) { final StorageException exceptionRef = new StorageException(StorageErrorCode.NONE.toString(), "Unexpected internal storage client error.", 306, // unused null, null); exceptionRef.initCause(cause); return exceptionRef; }
return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), "An unknown failure occurred : ".concat(message), HttpURLConnection.HTTP_INTERNAL_ERROR, null, cause); return translatedException; } else { return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), "The server encountered an unknown failure: ".concat(responseMessage), HttpURLConnection.HTTP_INTERNAL_ERROR, null, cause);
throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), "An unknown failure occurred : ".concat(message), HttpURLConnection.HTTP_INTERNAL_ERROR, null, cause);
currentKnownContainerState = ContainerState.Unknown; } catch (StorageException ex) { if (StorageErrorCode.RESOURCE_NOT_FOUND.toString() .equals(ex.getErrorCode())) { currentKnownContainerState = ContainerState.DoesntExist;
if (this.getLockedETag() != null) { if (!this.getLockedETag().equals(file.properties.getEtag())) { throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
if (this.getLockedETag() != null) { if (!this.getLockedETag().equals(file.properties.getEtag())) { throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
assertEquals(HttpURLConnection.HTTP_NOT_FOUND, e.getHttpStatusCode()); assertEquals("The specified container does not exist.", e.getMessage()); assertEquals(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), e.getErrorCode());
assertEquals(HttpURLConnection.HTTP_NOT_FOUND, e.getHttpStatusCode()); assertEquals("The specified container does not exist.", e.getMessage()); assertEquals(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), e.getErrorCode()); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, e.getHttpStatusCode()); assertEquals("The specified container does not exist.", e.getMessage()); assertEquals(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), e.getErrorCode()); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, e.getHttpStatusCode()); assertEquals("The specified container does not exist.", e.getMessage()); assertEquals(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), e.getErrorCode());