cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We just wanted to say thank you! Check out our customer appreciation video 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: 

Re: SwiftyDropbox, routeError not being generated

SwiftyDropbox, routeError not being generated

vewert
Explorer | Level 4
Go to solution

I'm just getting started with SwiftyDropbox, and am trying to get a better handle on Error Handling. I'm making a call to the /list_folder route, using dbClient.files.listFolder. If I put in a valid value for path, it all works great, but in order to test out the error hanlding I put invalid path (i.e. a path that doesn't exist.). From what I can tell from the Dropbox documentation, this should give a ListFolderError of type path LookupError.

Below is the code I am using (which is based on the examples in the SwiftyDropbox documentation):

 

dbClient.files.listFolder(path: "/Does not exist",
                              recursive: false,
                              includeMediaInfo: false,
                              includeDeleted: false,
                              includeHasExplicitSharedMembers: false,
                              includeMountedFolders: false,
                              limit: 15,
                              sharedLink: nil).response {response, error in
  if let response = response  {
    log.info("Dropbox Response:\n\(response)")
  } else if let error = error {
    log.error("Dropbox Error:\n\(error)")
    switch error as CallError {
      case .routeError(let boxed, let requestId, nil, nil):
        log.error("Route Error[\(requestId!)]")
        switch boxed.unboxed as Files.ListFolderError {
          case .path(let lookupError):
            log.error("Path Error: \(lookupError)")
            switch lookupError as Files.LookupError {
              case .malformedPath:
                log.error("Lookup Error: Malformed Path")
              case .notFound:
                log.error("Lookup Error: Not Found")
              case .notFile:
                log.error("Lookup Error: Not File")
              case .notFolder:
                log.error("Lookup Error: Not Folder")
              case .restrictedContent:
                log.error("Lookup Error: Restricted Content")
              default:
                log.error("Lookup Error: Non-specified")
            }
          case .other:
            log.error("Other Route Error")
        }
      case .clientError(let error):
        log.error("Client Error: \(error!)")
      case .badInputError(let message, let requestId):
        log.error("Bad input Error[\(requestId!)]: \(message!)")
      default:
        log.error("Other (Non-Route) Error")
    }
  }
}


 

The raw error that is output is as follows:


Dropbox Error:
[request-id 646c705e64c2cc76bd1b81925e5ea811] API route error - {
    ".tag" = path;
    path =     {
        ".tag" = "not_found";
    };
}

This seems right, so I would expect the error to be in the .routeError case, then .path case, and then in the .notFound case, and the output would be: "Lookup Error: Not Found"

but instead I get the following output: "Other (Non-Route) Error"

From the raw Dropbox error, it does look like I am getting the expected "path not_found" error, but for some reason it falls through into the "Non-Route" error case.

Am I doing something wrong, or am I misunderstanding how this should work?

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

It looks like the issue is just how you're checking the .routeError case. Instead of this:

case .routeError(let boxed, let requestId, nil, nil):

do this:

case .routeError(let boxed, _, _, let requestId):

or more completely:

case .routeError(let boxed, let userMessage, let errorSummary, let requestId):

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

It looks like the issue is just how you're checking the .routeError case. Instead of this:

case .routeError(let boxed, let requestId, nil, nil):

do this:

case .routeError(let boxed, _, _, let requestId):

or more completely:

case .routeError(let boxed, let userMessage, let errorSummary, let requestId):

vewert
Explorer | Level 4
Go to solution

Yes, that was the problem, thanks! I'm pretty new to this type of construct, with these switch cases that have parameters.

 

I was trying to find the documentation for CallError and .routeError but couldn't find it, and am still a little unclear about whole "boxed" thing.

 

Thanks.

Greg-DB
Dropbox Staff
Go to solution
Thanks! I'll ask the team to improve the documentation around this.

vewert
Explorer | Level 4
Go to solution
That's great! I really appreciate the quick response.
Need more support?