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
vewert
8 years agoExplorer | Level 4
SwiftyDropbox, routeError not being generated
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?
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):
- Greg-DBDropbox Staff
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):
- vewertExplorer | Level 4
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-DBDropbox StaffThanks! I'll ask the team to improve the documentation around this.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,885 PostsLatest Activity: 2 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!