You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Fahad G.'s avatar
Fahad G.
Explorer | Level 4
8 years ago

Java: How do handle 404 and 50x errors?

I'm migrating from V1 to V2.   In the past I an error code was an integer that I could look at. Now it's part of a string I presume (i.e. getMessage()).   There are no examples of how the errors ...
  • Greg-DB's avatar
    Greg-DB
    8 years ago

    Hi Fahad, if you're using the Dropbox API v2 Java SDK, the SDK will translate these 4xx or 5xx error responses into exceptions for you, so you don't have to parse them yourself.

     

    For instance, in the upload_file example here, there's some basic exception handling for some of the different kinds of exceptions that may get thrown.

     

    The uploadAndFinish method throws a few different types of exceptions. For example, DbxApiException covers some 4xx issues, and DbxException covers some other more general errors.

     

    That way, you don't need to know the specific error codes. You can check the type of the error for more granular error handling. For example, UploadErrorException is a subtype of DbxApiException, and covers some errors specific to uploading. (This would be a 409 from that endpoint.) Likewise, ServerException is a subtype of DbxException, and would indicate a server error. (That would be a 500.)

     

    You can continue checking nested errors for more and more specific information, such as via WriteError.isInsufficientSpace.

     

    Hope this helps! 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,883 PostsLatest Activity: 10 hours ago
326 Following

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 or Facebook.

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!