Dropbox API Downloading a file with every error case handled using the SwiftyDropbox library

Download Dropbox API for free

Example

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")
            }
            
    }
}
Downloading a file with metadata via curl in PHP