Forum Discussion

wizard1066's avatar
wizard1066
Explorer | Level 3
9 years ago

download timeout error message

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

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    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)")

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!