cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn about updates that we've made to the Search experience on the Android and iOS apps?Well, you can learn from Luke on the Mobile App team right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1
Ask
2
Reply and help

SwiftyDropbox error handing for thumbnails

SwiftyDropbox error handing for thumbnails

Mark L.45
Collaborator | Level 8

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
    }
}
1 Reply 1

Re: SwiftyDropbox error handing for thumbnails

Greg-DB
Dropboxer

Thanks for sharing! Yes, this looks good.

 

For reference, there's a similar example here:

 

https://stackoverflow.com/documentation/dropbox-api/408/downloading-a-file/1351/downloading-a-file-w...

 

(It was written for an earlier version of the SDK though, so the syntax may not be exactly right for the latest one.)

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?