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?