We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
David E.64
10 years agoNew member | Level 1
Download Error, how to extract info
Hi,
I am brand new to Swift, in fact only started looking at it in order to use swiftydropbox! Currently I don't see how to extract info from the downloadError without doing string finding jiggery ...
Greg-DB
Dropbox Community Moderator
10 years agoHi David, here's an example of using files.download with every error case handled in Swift: (apologies for the poor formatting on the forum)
Dropbox.authorizedClient!.files.download(path: path, destination: destination).response { response, error in
if let (metadata, url) = response {
print("*** Download file ***")
print("Downloaded file name: \(metadata.name)")
print("Downloaded file url: \(url)")
} else if let callError = error {
switch callError as CallError {
case .RouteError(let boxed, let requestId):
print("RouteError[\(requestId)]:")
switch boxed.unboxed as Files.DownloadError {
case .Path(let fileLookupError):
print("PathError: ")
switch fileLookupError {
case .MalformedPath(let malformedPathError):
print("MalformedPath: \(malformedPathError)")
case .NotFile:
print("NotFile")
case .NotFolder:
print("NotFolder")
case .NotFound:
print("NotFound")
case .RestrictedContent:
print("RestrictedContent")
case .Other:
print("Other")
}
case .Other:
print("Other")
}
case .BadInputError(let message, let requestId):
print("BadInputError[\(requestId)]: \(message)")
case .HTTPError(let code, let message, let requestId):
print("HTTPError[\(requestId)]: \(code): \(message)")
case .InternalServerError(let code, let message, let requestId):
print("InternalServerError[\(requestId)]: \(code): \(message)")
case .OSError(let err):
print("OSError: \(err)")
case .RateLimitError:
print("RateLimitError")
}
}
}
If I understand your question correctly, you can do the specific error detection in your Swift code, and then send whatever indicator or information you want back to the Objective-C side, as opposed to the error object or description itself.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!