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
billymeltdown
9 years agoExplorer | Level 4
Obj-C API v2 Error Handling
Hi folks, I find myself having more questions about error handling in the obj-c API v2. I keep going over the README and I am still unable to figure out where I should look for documentation on figur...
- 9 years ago
For each API call, you'll want to handle both the route error (for errors specific to that call) as well as the general error (for errors that can happen on any call).
For the route specific error for createFolder, which is DBFILESCreateFolderError, there is only the isPath case, since that error doesn't have any other scenarios. (The example in the README is for the delete call, which has a different set of possible route-specific errors, under DBFILESDeleteError.)
To see what is possible for any particular error, I recommend checking the Objective-C SDK documentation for that error type, e.g., DBFILESCreateFolderError, which lists just isPath. (You can look at the HTTP documenation, as you linked to, but the names won't always be exactly the same, as they get translated slightly for the SDK.)
So, if DBFILESCreateFolderError isPath is true, you can then access the DBFILESWriteError in it via the path field.
Here's a more elaborate sample for createFolder showing that:
[[client.filesRoutes createFolder:@"/test/path"] response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBError *error) { if (result) { NSLog(@"%@\n", result); } else if (routeError) { NSLog(@"%@\n", routeError); if ([routeError isPath]) { if ([routeError.path isConflict]) { if ([routeError.path.conflict isFolder]) { NSLog(@"Could not create folder because a folder already exists at path."); } else { // some other path conflict error: NSLog(@"%@\n", routeError.path.conflict); } } else if ([routeError.path isMalformedPath]) { NSLog(@"Could not create folder because the path is malformed."); } else { // and so on for other errors as desired // some other path error: NSLog(@"%@\n", routeError.path); } } } else if (error) { NSLog(@"%@\n", error); } }];
Greg-DB
Dropbox Staff
For each API call, you'll want to handle both the route error (for errors specific to that call) as well as the general error (for errors that can happen on any call).
For the route specific error for createFolder, which is DBFILESCreateFolderError, there is only the isPath case, since that error doesn't have any other scenarios. (The example in the README is for the delete call, which has a different set of possible route-specific errors, under DBFILESDeleteError.)
To see what is possible for any particular error, I recommend checking the Objective-C SDK documentation for that error type, e.g., DBFILESCreateFolderError, which lists just isPath. (You can look at the HTTP documenation, as you linked to, but the names won't always be exactly the same, as they get translated slightly for the SDK.)
So, if DBFILESCreateFolderError isPath is true, you can then access the DBFILESWriteError in it via the path field.
Here's a more elaborate sample for createFolder showing that:
[[client.filesRoutes createFolder:@"/test/path"] response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *routeError, DBError *error) { if (result) { NSLog(@"%@\n", result); } else if (routeError) { NSLog(@"%@\n", routeError); if ([routeError isPath]) { if ([routeError.path isConflict]) { if ([routeError.path.conflict isFolder]) { NSLog(@"Could not create folder because a folder already exists at path."); } else { // some other path conflict error: NSLog(@"%@\n", routeError.path.conflict); } } else if ([routeError.path isMalformedPath]) { NSLog(@"Could not create folder because the path is malformed."); } else { // and so on for other errors as desired // some other path error: NSLog(@"%@\n", routeError.path); } } } else if (error) { NSLog(@"%@\n", error); } }];
billymeltdown
9 years agoExplorer | Level 4
Ohhhhh, okay I get it! Thanks, Greg!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,909 PostsLatest Activity: 5 hours agoIf 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!