protected static StorageException translateFromHttpStatus ( final int statusCode , final String statusDescription , final Exception inner ) { String errorCode ; 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 : // 416: RequestedRangeNotSatisfiable - No corresponding enum in HttpURLConnection errorCode = StorageErrorCode . BAD_REQUEST . toString ( ) ; break ; case HttpURLConnection . HTTP_PRECON_FAILED : case HttpURLConnection . HTTP_NOT_MODIFIED : errorCode = StorageErrorCode . CONDITION_FAILED . toString ( ) ; break ; case HttpURLConnection . HTTP_CONFLICT : errorCode = StorageErrorCode . RESOURCE_ALREADY_EXISTS . toString ( ) ; break ; case HttpURLConnection . HTTP_UNAVAILABLE : errorCode = StorageErrorCode . SERVER_BUSY . toString ( ) ; break ; case HttpURLConnection . HTTP_GATEWAY_TIMEOUT : errorCode = StorageErrorCode . SERVICE_TIMEOUT . toString ( ) ; break ; case HttpURLConnection . HTTP_INTERNAL_ERROR : errorCode = StorageErrorCode . SERVICE_INTERNAL_ERROR . toString ( ) ; break ; case HttpURLConnection . HTTP_NOT_IMPLEMENTED : errorCode = StorageErrorCode . NOT_IMPLEMENTED . toString ( ) ; break ; case HttpURLConnection . HTTP_BAD_GATEWAY : errorCode = StorageErrorCode . BAD_GATEWAY . toString ( ) ; break ; case HttpURLConnection . HTTP_VERSION : errorCode = StorageErrorCode . HTTP_VERSION_NOT_SUPPORTED . toString ( ) ; break ; default : errorCode = null ; } if ( errorCode == null ) { return null ; } else { return new StorageException ( errorCode , statusDescription , statusCode , null , inner ) ; } }
Translates the specified HTTP status code into a storage exception .