-
Notifications
You must be signed in to change notification settings - Fork 734
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
How should I continue after handleErrorAsync inside a custom ApolloErrorInterceptor? #3368
Comments
Hi @avielg - when you receive an error like that it should be considered a terminal error re. the request so no you won't be able to continue from where the error was generated. You'd have to restart the request again. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better. |
@calvincestari Yeap I think my confusion was due to thinking that the error interceptor is an array like the regular interceptors - thinking that there might be other error interceptor that should also "get their turn" to do something with the error, but since there can only be one - I just need to pass the request to the original caller by calling the I wonder if it makes sense to have a small example showing this in the docs? Specifically where there are examples to the regular interceptors (https://www.apollographql.com/docs/ios/networking/request-pipeline/#example-interceptors), and the error interceptor is mentioned there, but without an example on usage? Something like this perhaps? class LoggerErrorInterceptor: ApolloErrorInterceptor {
weak var errorLogger: MyErrorLogger?
init(errorLogger: MyErrorLogger) {
self.errorLogger = errorLogger
}
func handleErrorAsync<Operation: GraphQLOperation>(
error: Error,
chain: RequestChain,
request: Apollo.HTTPRequest<Operation>,
response: Apollo.HTTPResponse<Operation>?,
completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void
) {
errorLogger?.requestFailed(response?.httpResponse, withError: error)
completion(.failure(error))
}
} |
Sure thing @avielg. I've got a PR up at apollographql/apollo-ios-dev#336 to add that, thanks for the suggestion. |
Amazing thanks! |
Question
I have an error interceptor, meant to log errors and notify users of my SDK via a delegate.
After I am done with the error inside
handleErrorAsync
, what should I do? Should I:proceedAsync(request:response:interceptor:completion:)
? (Assume no because I can't passself
as the interceptor, and the chain is done AFAIU?)chain.handleErrorAsync(request:response:completion:)
to pass the error to any other interceptor? Or will that just cause infinite loop?Thank you! 🙏
The text was updated successfully, but these errors were encountered: