Forum Discussion

Mark L.45's avatar
Mark L.45
Collaborator | Level 9
9 years ago

SwiftyDropbox error handing for thumbnails

Finishing off my dropbox based app and trying to put in some comprehensive error code. Downloading thumbnails within it and crafted this method based on the documentation. Seems to work, but wanted to double check I am on the right track.

 

func doThumbError(error: Any) {
    switch error as! CallError<SwiftyDropbox.Files.ThumbnailError> {
    case .routeError(let boxed, let requestId):
        switch boxed.unboxed {
        case .conversionError: break
        case .unsupportedExtension:break
        case .unsupportedImage:break
        case .path(let lookupError):
            switch lookupError {
            case .notFound:
                print("There is nothing at the given path.")
                break
            case .notFile:
                print("We were expecting a file, but the given path refers to something that isn't a file.")
                break
            case .notFolder:
                print("We were expecting a folder, but the given path refers to something that isn't a folder.")
                break
            case .restrictedContent:
                print("The file cannot be transferred because the content is restricted...")
                break
            case .malformedPath(let malformedPath):
                print("Malformed path: \(malformedPath)")
                break
            default:
                print("Unknown \(error)")
                break
            }
        }
    case .internalServerError(let code, let message, let requestId):
        print("InternalServerError[\(requestId)]: \(code): \(message)")
        break
    case .badInputError(let message, let requestId):
        print("BadInputError[\(requestId)]: \(message)")
        break
    case .authError(let authError, let requestId):
        print("AuthError[\(requestId)]: \(authError)")
        break
    case .rateLimitError(let rateLimitError, let requestId):
        print("RateLimitError[\(requestId)]: \(rateLimitError)")
        break
    case .httpError(let code, let message, let requestId):
        print("HTTPError[\(requestId)]: \(code): \(message)")
        break
    case .clientError(let error):
        print("ClientError: \(error)")
        break
    }
}

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,951 PostsLatest Activity: 44 minutes ago
352 Following

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 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!