Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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 would look like if these are 40x errors or 50x errors. How do I handle these? What should I expect, say, if the storage has run out on the server? Previously we used to get a 507 error (as in integer), what should I now expect?
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!
In the file DbxRequestUtil.java, method parseErrorBody, I can see that statusCode is not used / appended to the body of the error message. This does not help as we need to be able to handle these errors reliably. What makes it more difficult is that unless you specify the locale to be 'en', all messages are localized, effectively rendering our parsing routines useless.
What I need to do is reliably parse and handle error codes. There's certain part of our app's logic that needs to be triggered, and not just an error displayed. How can I reliably do this with v2?
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!
Hi there!
If you need more help you can view your support options (expected response time for a 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!