We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

billymeltdown's avatar
billymeltdown
Explorer | Level 4
9 years ago

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...
  • Greg-DB's avatar
    Greg-DB
    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);
                }
            }];

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,878 PostsLatest Activity: 5 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!