com.dropbox.client2.exception
Class DropboxServerException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.dropbox.client2.exception.DropboxException
              extended by com.dropbox.client2.exception.DropboxServerException
All Implemented Interfaces:
java.io.Serializable

public class DropboxServerException
extends DropboxException

Wraps any non-200 HTTP responses from an API call. See the constants in this class for the meaning of each error code. You'll typically only want to handle a few specific error codes and show some kind of generic error or retry for the rest.

See Also:
Serialized Form

Nested Class Summary
static class DropboxServerException.Error
           
 
Field Summary
static int _200_OK
          The request was successful.
static int _302_FOUND
          Moved to a new location temporarily.
static int _304_NOT_MODIFIED
          Contents have not changed (from the given hash, revision, ETag, or similar parameter).
static int _400_BAD_REQUEST
          Bad input parameter.
static int _401_UNAUTHORIZED
          Bad or expired access token.
static int _403_FORBIDDEN
          Usually from an invalid app key pair or other permanent error.
static int _404_NOT_FOUND
          Path not found.
static int _405_METHOD_NOT_ALLOWED
          Request method not allowed.
static int _406_NOT_ACCEPTABLE
          Too many metadata entries to return.
static int _409_CONFLICT
           
static int _411_LENGTH_REQUIRED
          Typically from trying to upload over HTTP using chunked encoding.
static int _415_UNSUPPORTED_MEDIA
          When a thumbnail cannot be created for the input file.
static int _500_INTERNAL_SERVER_ERROR
          Internal server error.
static int _501_NOT_IMPLEMENTED
          Not implemented.
static int _502_BAD_GATEWAY
          If a Dropbox server is down - try again later.
static int _503_SERVICE_UNAVAILABLE
          If a Dropbox server is not working properly - try again later.
static int _507_INSUFFICIENT_STORAGE
          User is over quota.
 DropboxServerException.Error body
          The body, if any, of the returned error.
 int error
          The HTTP error code.
 java.lang.String location
          The location string from the headers (to handle redirects).
 java.util.Map<java.lang.String,java.lang.Object> parsedResponse
           
 java.lang.String reason
          The reason string associated with the error.
 java.lang.String server
          The server string from the headers.
 
Constructor Summary
DropboxServerException(org.apache.http.HttpResponse response)
          Creates a DropboxServerException from an HttpResponse.
DropboxServerException(org.apache.http.HttpResponse response, java.lang.Object rest)
          Creates a DropboxServerException from an HttpResponse.
 
Method Summary
 boolean isDuplicateAccount()
          When this exception comes from creating a new account, returns whether the request failed because an account with the email address already exists.
static boolean isValidWithNullBody(org.apache.http.HttpResponse response)
          Whether the given response is valid when it has no body (only some error codes are allowed without a reason, currently 302 and 304).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_200_OK

public static final int _200_OK
The request was successful. This won't ever be thrown in an exception.

See Also:
Constant Field Values

_302_FOUND

public static final int _302_FOUND
Moved to a new location temporarily.

See Also:
Constant Field Values

_304_NOT_MODIFIED

public static final int _304_NOT_MODIFIED
Contents have not changed (from the given hash, revision, ETag, or similar parameter).

See Also:
Constant Field Values

_400_BAD_REQUEST

public static final int _400_BAD_REQUEST
Bad input parameter. Error message should indicate which one and why.

See Also:
Constant Field Values

_401_UNAUTHORIZED

public static final int _401_UNAUTHORIZED
Bad or expired access token. Need to re-authenticate user.

See Also:
Constant Field Values

_403_FORBIDDEN

public static final int _403_FORBIDDEN
Usually from an invalid app key pair or other permanent error.

See Also:
Constant Field Values

_404_NOT_FOUND

public static final int _404_NOT_FOUND
Path not found.

See Also:
Constant Field Values

_405_METHOD_NOT_ALLOWED

public static final int _405_METHOD_NOT_ALLOWED
Request method not allowed. You shouldn't see this unless writing your own API calls.

See Also:
Constant Field Values

_406_NOT_ACCEPTABLE

public static final int _406_NOT_ACCEPTABLE
Too many metadata entries to return.

See Also:
Constant Field Values

_409_CONFLICT

public static final int _409_CONFLICT
See Also:
Constant Field Values

_411_LENGTH_REQUIRED

public static final int _411_LENGTH_REQUIRED
Typically from trying to upload over HTTP using chunked encoding. The Dropbox API currently does not support chunked transfer encoding.

See Also:
Constant Field Values

_415_UNSUPPORTED_MEDIA

public static final int _415_UNSUPPORTED_MEDIA
When a thumbnail cannot be created for the input file.

See Also:
Constant Field Values

_500_INTERNAL_SERVER_ERROR

public static final int _500_INTERNAL_SERVER_ERROR
Internal server error. Best to try again or wait until corrected by Dropbox.

See Also:
Constant Field Values

_501_NOT_IMPLEMENTED

public static final int _501_NOT_IMPLEMENTED
Not implemented.

See Also:
Constant Field Values

_502_BAD_GATEWAY

public static final int _502_BAD_GATEWAY
If a Dropbox server is down - try again later.

See Also:
Constant Field Values

_503_SERVICE_UNAVAILABLE

public static final int _503_SERVICE_UNAVAILABLE
If a Dropbox server is not working properly - try again later.

See Also:
Constant Field Values

_507_INSUFFICIENT_STORAGE

public static final int _507_INSUFFICIENT_STORAGE
User is over quota.

See Also:
Constant Field Values

body

public DropboxServerException.Error body
The body, if any, of the returned error.


error

public int error
The HTTP error code.


reason

public java.lang.String reason
The reason string associated with the error.


server

public java.lang.String server
The server string from the headers.


location

public java.lang.String location
The location string from the headers (to handle redirects).


parsedResponse

public java.util.Map<java.lang.String,java.lang.Object> parsedResponse
Constructor Detail

DropboxServerException

public DropboxServerException(org.apache.http.HttpResponse response)
Creates a DropboxServerException from an HttpResponse.


DropboxServerException

public DropboxServerException(org.apache.http.HttpResponse response,
                              java.lang.Object rest)
Creates a DropboxServerException from an HttpResponse. The rest parameter must be a Map of String to Object.

Method Detail

isDuplicateAccount

public boolean isDuplicateAccount()
When this exception comes from creating a new account, returns whether the request failed because an account with the email address already exists.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Throwable

isValidWithNullBody

public static boolean isValidWithNullBody(org.apache.http.HttpResponse response)
Whether the given response is valid when it has no body (only some error codes are allowed without a reason, currently 302 and 304).