Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting statuses #23

Open
anthonyroux opened this issue Jul 15, 2020 · 0 comments
Open

Conflicting statuses #23

anthonyroux opened this issue Jul 15, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@anthonyroux
Copy link
Contributor

Reported by Feng

There are conflicting statuses:

I was following the process() function in Request.swift (see below), error says ("The request timed out."); the response says success (Status Code: 200,); data is nil. The three messages are not consistent, which causes a runtime error (Thread 8: Fatal error: Unexpectedly found nil while unwrapping an Optional value), when unwrapping "data".

private func process(request: NSMutableURLRequest,
                  onCompletion: @escaping AmadeusResponse) {
    let session = URLSession.shared
    let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in

        var amadeusResponse: Response?
        var amadeusError: ResponseError?

        if let httpResponse = response as? HTTPURLResponse {
            // got a valid HTTP answer
            amadeusResponse = Response(response: httpResponse, data: data!)
            // Error could be either nil (200 OK) or enum value
            amadeusError = amadeusResponse!.getErrorCode()
        } else {
            // no HTTP answer: network problem
            amadeusResponse = nil
            amadeusError = ResponseError.returnedError(error!)
        }
        onCompletion(amadeusResponse, amadeusError)
    })
    task.resume()
}```
@anthonyroux anthonyroux added the bug Something isn't working label Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants