Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Graham B.'s avatar
Graham B.
New member | Level 2
9 years ago

[Java SDK v2] migration: error handling with HTTP codes

I'm migrating to the v2 Java SDK on Android, from the old Android SDK. I'm struggling to convert some error-handling code. This is a high-level error handler which could be handling an exception from any one of a number of Dropbox API methods.

 

Here's how it used to look:

 

 

 

if (DropboxServerException.class.isInstance(exception)) { 
    switch (((DropboxServerException) exception).error) { 
        case DropboxServerException._401_UNAUTHORIZED: 
        case DropboxServerException._403_FORBIDDEN: 
        case DropboxServerException._404_NOT_FOUND: 
            Log.w(TAG, "data has moved/disappeared, or something equally terminal."); 
            // do some error handling
            break; 
    }
}

 Now it looks as if I'm supposed to examine any one of dozens of different DbxApiException subclasses, and try to extract a meaningful error code from their messages. Please tell me there's a better way?

 
 
 
 
 

1 Reply

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!