-
Notifications
You must be signed in to change notification settings - Fork 126
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
Interceptors not called if converters throws an exception #167
Comments
Need to investigate this. Thx! |
Hola @danielgomezrico bro eso me pasaba a mi, la solucion a eso fue crear un mapa de funciones para llamar al parser del json a la clase que necesitas ejemplo
en el metodo convertResponse del converter hago algo como:
el metodo fromJsonData es
|
If I get it correctly, Interceptors not being called is not the real problem here. First, we should focus on making the exception more informative. |
@stewemetal that's true in part, if the exception can have the full response and the parts that fail it would be awesome, I just thought that it will be good to see the response with the headers and all of the prints that the interceptors prints will add value too. |
@Jparrgam gracias pero no agarre tu idea, los ejemplos no son claros, puedes desarrollar la idea mejor? depronto si lo haces en ingles quedaría más accesible para el resto. |
I doesn't solve the cause of the exception. But I added a test see #600 to verify that exception are passed up in the interceptor chain. This doesn't mean that all the interceptors are "called" and "executed" but could theoretically catch these exception and do something. Interceptor that can catch the exception are only called for the request and receive the exception instead of the response on the way back I guess. |
I understand the Interceptor are not throwing the exception but I don't understand what is expected when a exception is thrown by the Converter. I don't think it matter where the exception is thrown. If something is thrown either in the converter or the interceptor you need to deal/resolve the exception in order to continue. We cannot throw the exception and continue with the converter or interceptor. If you want to print information about the response even though there is a exception this can also be done in the converter I guess. Can you provide us with a example of what you want to achieve? |
The use that breaks to me is that:
When the converter fails, I cannot see in the logs the response body, so I can fix it, I just see a big the exception saying I was expecting a String and got null. It is not enough to understand what else is bad, and so I was expecting to be able to see the logs from the interceptor so see the full body of the request |
Thanks for elaborating more on the issue. I don't think there's much we can do. One way I can think of is providing a way to insert a "logging" interceptor before the converters. But I think that would make the library less developer friendly and also creates other openings for weird behaviour if used incorrectly(what will happen with developers 😉 ). Another way to get closer to the actual calls, could be by providing a custom HttpClient (wrapper) that does the logging for you. This way you sort of skip the chopper stuff regarding response handling. I also don't necessarily thing this is a bug. The exception is there for a reason and needs to be solved. If the exception is not from Chopper itself its hard for us to clarify whats happing. For chopper and interceptor to work, the converter needs to resolve this in order to continue. Ofcourse we can try to provide tools to make debugging and inspecting easier. But in that case there are also third party tools available. For example using dart dev tool and the http inspector or regular debugging. @techouse Do you have any other ideas or insights? |
This should be logged in Crashlyitics anyway.
Agreed. Your service call fails because of bad data and your app should not display bad data. For example, it's wiser to show an error screen than an incorrect bank account balance to the user. @Guldem pretty much summed it up. Either you provide a custom Closing this issue. |
Excuse me 🙈 I disagree with the idea that this is not a bug, I know that it could be difficult to fix but that's another conversation. Think about this other use case (which I lived in the past, and now I realize that we could have a bug if this happens): This idea of creating a hole Client for this may work, but it is not the responsibility of Chopper itself, and that's one of the reasons of why the interceptors exist? |
Yes that indeed why interceptors exist, only with the requirement that the request can be converted and the flow doesn't throw errors. The other idea behind chopper is that it can automatically convert requests to a specific type. Which causes a conflict. Regarding your example. I think this is a very specific use case, which can also be solve by providing the custom client. I also think that the converter should not need to throw parsing exceptions if implemented correctly. front-end & back-end should implement the same interface. Especially in valid requests. |
Currently if theres an exception from the converters then the interceptors are not called, it does not print the response.
You just get a trace like the next one but it is hard to debug what was the answer that resulted into this:
But you dont get the print from the
HttpLoggingInterceptor
.The text was updated successfully, but these errors were encountered: