Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Joe Z.1's avatar
Joe Z.1
Explorer | Level 3
9 years ago

Swift SDK - no code returned for 'HTTPError'

I am using the Swift SDK v2 and I want to be able to interpret errors returned when there is no internet connection. So for 

files.listFolder

the returned error only contains a description saying "HTTP Error:" without any code or anything else. When I try to switch on HTTPError as suggested here, I am getting the following:

"http error code: nil - message: Optional("") - requestID: nil"

for the following code:

 

                if let error = error {
                    switch error {
                    case let .HTTPError(code, message, requestID):
                        print("http error code: \(code) - message: \(message) - requestID: \(requestID) ")
                    default:
                        print("some other error")
                    }
                } else {
                    print("there was no error")
                } 

2 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    Hi Joe, when offline, the HTTPError case doesn't contain any useful specific HTTP error information as you saw (since there was no response to use). For now you can just consider this case to be a general network failure, but I'll send this along as a feature request to expose the more specific underlying error from the network connection.

  • Joe Z.1's avatar
    Joe Z.1
    Explorer | Level 3
    9 years ago

    Hi Gregory, thanks for the confirmation, maybe something more descriptive like Swift's

    NSURLErrorNotConnectedToInternet

    would be very helpful. Thanks for all your support!

    Take Care .. Joe

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!