cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Re: download timeout error message

download timeout error message

wizard1066
Explorer | Level 3

I am trying to access slides in a folder, and seeing this error when I downloading them thru SwiftyDropbox API. 

 

I want to write code to retry said downloads, but how to capture this verbose description to make sure I am retrying for a code -1001.

 

My errorcode looks like this?

 

ClientError: Optional(Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=https://api-content.dropbox.com/2/files/download, NSErrorFailingURLKey=https://api-content.dropbox.com/2/files/download, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.})

 

The code that prints this look like this ...

 

 func doDownloadError(error: Any, errorSource: String) {

        //rint("doDownloadError")

        switch error as! CallError<SwiftyDropbox.Files.DownloadError> {

        case .routeError(let boxed, let requestId):

            switch boxed.unboxed {

            case .path(let lookupError):

                switch lookupError {

                case .notFound:

                    ////rint("There is nothing at the given path.")

                    NotificationCenter.default.post(name: Notification.Name("dbNotFound"), object: nil, userInfo: nil)

                    break

                case .notFile:

                    ////rint("We were expecting a file, but the given path refers to something that isn't a file.")

                    NotificationCenter.default.post(name: Notification.Name("dbNotFile"), object: nil, userInfo: nil)

                    break

                case .notFolder:

                    ////rint("We were expecting a folder, but the given path refers to something that isn't a folder.")

                    NotificationCenter.default.post(name: Notification.Name("dbNotFolder"), object: nil, userInfo: nil)

                    break

                case .restrictedContent:

                    ////rint("The file cannot be transferred because the content is restricted...")

                    NotificationCenter.default.post(name: Notification.Name("dbRestrictedContent"), object: nil, userInfo: nil)

                    break

                case .malformedPath(let malformedPath):

                    ////rint("Malformed path: \(malformedPath)")

                    NotificationCenter.default.post(name: Notification.Name("dbMalformedPath"), object: nil, userInfo: nil)

                    break

                default:

                    ////rint("Unknown \(error)")

                    break

                }

            default:

                ////rint("Unknown \(error)")

                break

            }

        case .internalServerError(let code, let message, let requestId):

            ////rint("InternalServerError[\(requestId)]: \(code): \(message)")

            NotificationCenter.default.post(name: Notification.Name("dbInternalServerError"), object: nil, userInfo: nil)

            break

        case .badInputError(let message, let requestId):

            ////rint("BadInputError[\(requestId)]: \(message)")

            NotificationCenter.default.post(name: Notification.Name("dbBadInputError"), object: nil, userInfo: nil)

            break

        case .authError(let authError, let requestId):

            ////rint("AuthError[\(requestId)]: \(authError)")

            NotificationCenter.default.post(name: Notification.Name("dbAuthError"), object: nil, userInfo: nil)

            break

        case .rateLimitError(let rateLimitError, let requestId):

            ////rint("RateLimitError[\(requestId)]: \(rateLimitError)")

            NotificationCenter.default.post(name: Notification.Name("dbRateLimitError"), object: nil, userInfo: nil)

            break

        case .httpError(let code, let message, let requestId):

            ////rint("HTTPError[\(requestId)]: \(code): \(message)")

            NotificationCenter.default.post(name: Notification.Name("dbHTTPError"), object: nil, userInfo: nil)

            break

        case .clientError(let error):

            print("ClientError: \(error.debugDescription) \(errorSource)")

            NotificationCenter.default.post(name: Notification.Name("dbClientError"), object: nil, userInfo: nil)

            break

        }

    }

 

 

1 Reply 1

Greg-DB
Dropbox Staff

You can cast that error as NSError to access the specific parts of the error information, such as:

 

case .clientError(let clientError as NSError):
    print("ClientError code: \(clientError.code)")
    print("ClientError domain: \(clientError.domain)")
Need more support?