You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to handle errors when internet connection is off
I was wondering how can we get the localized description of the underlying error from func networkTransport(_ networkTransport: HTTPNetworkTransport, receivedError error: Error, for request: URLRequest, response: URLResponse?, continueHandler: @escaping (HTTPNetworkTransport.ContinueAction) -> Void)
Because when printing the error.localizedDescription from this delegate function we get the message The operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.)" which is not a great message to display to users.
The text was updated successfully, but these errors were encountered:
Ah i need to add some LocalizedError support to that in general, but you should be able to switch on the various cases of URLSessionClientError to figure out which error you're getting there.
(Note that even with the URLSessionClientError getting error descriptions, I'd still recommend switching on the error you get, because each of the error types comes with additional details, like an exact error returned by the system and/or data returned from your server)
Thank you, by switching on the error I got what I wanted :).
switch error {
case URLSessionClient.URLSessionClientError.networkError(let data, let response, let underlying):
continueHandler(.fail(underlying))
default:
continueHandler(.fail(error))
}
Hi, I'm trying to handle errors when internet connection is off
I was wondering how can we get the localized description of the underlying error from
func networkTransport(_ networkTransport: HTTPNetworkTransport, receivedError error: Error, for request: URLRequest, response: URLResponse?, continueHandler: @escaping (HTTPNetworkTransport.ContinueAction) -> Void)
Because when printing the
error.localizedDescription
from this delegate function we get the messageThe operation couldn’t be completed. (Apollo.URLSessionClient.URLSessionClientError error 2.)"
which is not a great message to display to users.The text was updated successfully, but these errors were encountered: