cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Improvements to the Dropbox v2 Objective-C SDK

Improvements to the Dropbox v2 Objective-C SDK

philipkd
Helpful | Level 5

I was wondering if there are any plans to improve the error reporting/handling in the Obj-C Dropbox v2 SDK? I have a lot of different calls, and 99% of the time they work, but in the other 1% of the time, I'd like something simple and legible to display to the user. I'll probably end up making a helper function that will have maybe 20-40 different messages. Time-wise, that might not be so bad, but it will be a headache to implement, and more so, I'm worried about my accuracy in matching what's in the SDK. On my first stab at it, I got terribly lost, even with Greg's assist.

 

In the v1 SDK, if a call didn't work, I usually could get away with using something like [error description].

 

 

You guys have already been incredibly supportive of developers, so thanks for that.

 

- Phil

6 Replies 6

Re: Improvements to the Dropbox v2 Objective-C SDK

Greg-DB
Dropboxer
Hi Phil, we're still working on improvements to the SDK, but I can't make any particular promises as to what will or won't be implemented.

Can you elaborate on the changes you'd like to see specifically though? I'll be happy to send it along as feedback. It sounds like you want some sort of catch-all error message supplied by Dropbox that you can display to the user? What would the interface look like ideally? Thanks in advance!

Re: Improvements to the Dropbox v2 Objective-C SDK

philipkd
Helpful | Level 5

Thank you so much, Greg.

 

This would be my ideal flow:

 

[[client.filesRoutes alphaGetMetadata:cloudPath includeMediaInfo:[NSNumber numberWithBool:NO] includeDeleted:[NSNumber numberWithBool:YES] includeHasExplicitSharedMembers:[NSNumber numberWithBool:NO] includePropertyTemplates:nil] response:^(DBFILESMetadata *metadata, DBFILESAlphaGetMetadataError *routeError, DBError *error) {
        
        if (metadata)
            // do something
        else if (some special case on routeError that I can handle)
            // do something different
        else
            [NotesAlerts showAlertWithString:[NSString stringWithFormat:@"%@",error];

}];

 

An example alert would say, "Bad input (cannot use "//" in file name)" or something like that. A short message that had the error type followed by details would be great. That way users can either self-troubleshoot or, barring that, can email me with some detailed feedback.

 

What I currently have is wonky:

 

 

[NotesAlerts showAlertWithString:[NotesAlerts errorNameForRouteError:routeError genericError:error]]

 

 

And this is the start of my error-handler:

 

 

+ (NSString *) nameForRouteError:(DBRouteErrorCast *) error {
    
    if (ISA(error,DBFILESUploadError)) {
        DBFILESUploadError *e = (DBFILESUploadError *) error;
        if (e.isPath)
            return [NSString stringWithFormat:@"Write Failed (%@)",e.path.reason];
        return [NSString stringWithFormat:@"Write Failed (%@)",e];
        
    }
    
    if (ISA(error,DBFILESDownloadError)) {
        DBFILESDownloadError *e = (DBFILESDownloadError *) error;
        if (e.isPath) {
            if (e.path.isMalformedPath)
                return [NSString stringWithFormat:@"Malformed Path (%@)",e.path.malformedPath];
            if (e.path.isNotFound)
                return @"Not Found";
            if (e.path.isNotFile)
                return @"Not a File";
            if (e.path.isNotFolder)
                return @"Not a Folder";
            if (e.path.isRestrictedContent)
                return @"Restricted Content";
            return [NSString stringWithFormat:@"Lookup Error (%@)",e];
        }
        return [NSString stringWithFormat:@"Download Error (%@)",e];
    }
 

 

It does the "isPath", "isWhatever", ... and constructs the specific error for that case. When it can't catch the is__ it just spits out whatever the object's description is. But when I tried it with an old version of the SDK (Oct-2016), I tried forcing a specific error, my is__ couldn't catch it, nor was the pass-through to the error's description human-readable. Neither the routeError nor the generic error triggered the appropriate message in my logic. I just updated the SDK recently, so hopefully that fixes things. But I'm still nervous, because I don't think I can test every error to make sure I have an appropriate message.

Re: Improvements to the Dropbox v2 Objective-C SDK

Greg-DB
Dropboxer
Thanks for the detailed reply! This is really helpful feedback. I can't make any promises, but I'm sending it along to the team now.

Re: Improvements to the Dropbox v2 Objective-C SDK

Greg-DB
Dropboxer

As of the latest version of the SDK (v3.0.1), userMessage is now exposed as a field of DBRequestError as well as DBRequestHttpError and its subclasses. It isn't always set, but when it is you can display the message to the user.

Re: Improvements to the Dropbox v2 Objective-C SDK

philipkd
Helpful | Level 5

Awesome, thank you!

Re: Improvements to the Dropbox v2 Objective-C SDK

Gnasher
Explorer | Level 3

My approach to the handling of errors was:

 

 

[[[DropboxClientsManager authorizedClient].filesRoutes downloadData:@"somepath"] response:^(DBFILESFileMetadata * _Nullable response, DBFILESDownloadError * _Nullable downloadError, DBRequestError * _Nullable requestError, NSData * _Nonnull data) {
      if (downloadError || requestError) {
          MTError * error = [MTError errorWithDBErrorObject:downloadError ? downloadError : requestError];          [error reportErrorWhileAttempting:@"Download"];
      }
      else {
          // Do something with the results
      }
}];

 

 

Its not comprehesive yet, I add to it as I run into an unhandled error type.  If interested I can provide the source (Obj-C ).

 

 

 

 

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Gnasher Explorer | Level 3
  • User avatar
    philipkd Helpful | Level 5
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?