microsoft-azure-storage/src/com/microsoft/azure/storage/StorageException.java
public static StorageException translateException(final StorageRequest<?, ?, ?> request, final Exception cause,
            final OperationContext opContext) {
        if (request == null || request.getConnection() == null) {
            return translateClientException(cause);
        }
        
        if (cause instanceof SocketException) {
            String message = cause == null ? Constants.EMPTY_STRING : cause.getMessage();
            return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(),
                    "An unknown failure occurred : ".concat(message), HttpURLConnection.HTTP_INTERNAL_ERROR,
                    null, cause);
        }

        StorageException translatedException = null;

        String responseMessage = null;
        int responseCode = 0;
        try {
            responseCode = request.getConnection().getResponseCode();
            responseMessage = request.getConnection().getResponseMessage();
        } catch (final IOException e) {
            // ignore errors
        }

        if (responseMessage == null) {
            responseMessage = Constants.EMPTY_STRING;
        }

        StorageExtendedErrorInformation extendedError = request.parseErrorDetails();
        if (extendedError != null) {
            // 1. If extended information is available use it
            translatedException = new StorageException(extendedError.getErrorCode(), responseMessage, responseCode,
                    extendedError, cause);
        } else {
            // 2. If extended information is unavailable, translate exception based
            // on status code
            translatedException = translateFromHttpStatus(responseCode, responseMessage, cause);   
        }

        if (translatedException != null) {
            Utility.logHttpError(translatedException, opContext);
            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);   
        }
    }
public static StorageException translateException(final StorageRequest<?, ?, ?> request, final Exception cause,
            final OperationContext opContext) {
        if (request == null || request.getConnection() == null) {
            return translateClientException(cause);
        }
        
        if (cause instanceof SocketException) {
            String message = cause == null ? Constants.EMPTY_STRING : cause.getMessage();
            return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(),
                    "An unknown failure occurred : ".concat(message), HttpURLConnection.HTTP_INTERNAL_ERROR,
                    null, cause);
        }

        StorageException translatedException = null;

        String responseMessage = null;
        int responseCode = 0;
        try {
            responseCode = request.getConnection().getResponseCode();
            responseMessage = request.getConnection().getResponseMessage();
        } catch (final IOException e) {
            // ignore errors
        }

        if (responseMessage == null) {
            responseMessage = Constants.EMPTY_STRING;
        }

        StorageExtendedErrorInformation extendedError = request.parseErrorDetails();
        if (extendedError != null) {
            // 1. If extended information is available use it
            translatedException = new StorageException(extendedError.getErrorCode(), responseMessage, responseCode,
                    extendedError, cause);
        } else {
            // 2. If extended information is unavailable, translate exception based
            // on status code
            translatedException = translateFromHttpStatus(responseCode, responseMessage, cause);   
        }

        if (translatedException != null) {
            Utility.logHttpError(translatedException, opContext);
            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);   
        }
    }
public static StorageException translateException ( final StorageRequest < ? , ? , ? > request , final Exception cause , final OperationContext opContext ) { if ( request == null || request . getConnection ( ) == null ) { return translateClientException ( cause ) ; } if ( cause instanceof SocketException ) { String message = cause == null ? Constants . EMPTY_STRING : cause . getMessage ( ) ; return new StorageException ( StorageErrorCode . SERVICE_INTERNAL_ERROR . toString ( ) , "An unknown failure occurred : " . concat ( message ) , HttpURLConnection . HTTP_INTERNAL_ERROR , null , cause ) ; } StorageException translatedException = null ; String responseMessage = null ; int responseCode = 0 ; try { responseCode = request . getConnection ( ) . getResponseCode ( ) ; responseMessage = request . getConnection ( ) . getResponseMessage ( ) ; } catch ( final IOException e ) { // ignore errors } if ( responseMessage == null ) { responseMessage = Constants . EMPTY_STRING ; } StorageExtendedErrorInformation extendedError = request . parseErrorDetails ( ) ; if ( extendedError != null ) { // 1. If extended information is available use it translatedException = new StorageException ( extendedError . getErrorCode ( ) , responseMessage , responseCode , extendedError , cause ) ; } else { // 2. If extended information is unavailable, translate exception based // on status code translatedException = translateFromHttpStatus ( responseCode , responseMessage , cause ) ; } if ( translatedException != null ) { Utility . logHttpError ( translatedException , opContext ) ; 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 ) ; } }
RESERVED FOR INTERNAL USE. Translates the specified exception into a storage exception.

@param request
An <code>HttpURLConnection</code> object that represents the request whose exception is being
translated.
@param cause
An <code>Exception</code> object that represents the exception to translate.

@return A <code>StorageException</code> object that represents translated exception.
RESERVED FOR INTERNAL USE . Translates the specified exception into a storage exception .