Dropbox API Sharing a folder with every error case handled using the SwiftyDropbox library


Example

This uses the SwiftyDropbox library to share a folder, handling every error case:

Dropbox.authorizedClient!.sharing.shareFolder(path: "/folder_path").response { response, error in
    if let result = response {
        print("response: \(result)")
    } else if let callError = error {
        switch callError as CallError {
        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")
        case .RouteError(let boxed, let requestId):
            print("RouteError[\(requestId)]:")
            switch boxed.unboxed as Sharing.ShareFolderError {
            case .BadPath(let sharePathError):
                print("BadPath: \(sharePathError)")
                switch sharePathError as Sharing.SharePathError {
                case .AlreadyShared:
                    print("AlreadyShared")
                case .ContainsSharedFolder:
                    print("ContainsSharedFolder")
                case .InsideAppFolder:
                    print("InsideAppFolder")
                case .InsideSharedFolder:
                    print("InsideSharedFolder")
                case .InvalidPath:
                    print("InvalidPath")
                case .IsAppFolder:
                    print("IsAppFolder")
                case .IsFile:
                    print("IsFile")
                case .Other:
                    print("Other")
                }
            case .EmailUnverified:
                print("EmailUnverified")
            case .TeamPolicyDisallowsMemberPolicy:
                print("TeamPolicyDisallowsMemberPolicy")
            case .Other:
                print("Other")
            }
        }
    }
}