-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
GlideException doesn't return anymore HTTP response code #1967
Comments
If you'd like to add a section to the migrating documentation I'd welcome a pull request, see http://bumptech.github.io/glide/dev/contributing.html#documentation |
Ok thanks, I've seen that method in the documentation, but it's returning an empty list. |
@fasteque can you debug and follow the path of https://github.com/bumptech/glide/blob/master/library/src/main/java/com/bumptech/glide/load/data/HttpUrlFetcher.java#L116 to see where it may be lost? |
Sure, I come back to you when I have something, thanks. |
Note: I have removed the code to set OkHttp in my custom GlideModule. I don't get to that point or in general that class.
Logs:
|
@sjudd swallowing a non-2xx error code like that is nasty. It is not a dropin-compatible replacement for the default fetcher, I think /**
* Returns true if the code is in [200..300), which means the request was successfully received,
* understood, and accepted.
*/
public boolean isSuccessful() {
return code >= 200 && code < 300;
} |
Breakpoint in |
This is where the failure notification is sent for my use case:
|
Actually you can easily test on your side too, just passing an invalid access token If you open this in Chrome you see |
I'll try and take a look. I'd expect the logging in the OkHttp response only gets called if onError is also called? I'm not sure what it means if OkHttp's onError callback is not called but the response is not successful. I'd assume any failure would trigger the onError callback. |
Ok I think I get it, onError is called if the request itself fails (connection failure), onResponse is called otherwise if the request is made. Easy to fix, thanks for the report! |
Glide Version: 4.0.0-RC0
Integration libraries: okhttp3-integration:4.0.0-RC0
Device/Android Version: Android TV emulator X86, Android 7.0
Issue details / Repro steps / Use case background:
I'm upgrading my application from version
3.8.0
to the4.0.0-RC0
and I have to manage errors when I load images from a remote service, which require authentication.In
3.8.0
, once the session is expired or not valid anymore, the service reply with a 401 error and what I get in the Glide listener is aIOException
and the message is the original sent from the server, so I can do a very simple check on it and look for 401.Example:
Request failed with code: 401
In
4.0.0-RC0
, theGlideException
cannot be casted anymore toIOException
(instanceof
returnsfalse
) but even worse the message of the exception is a genericFailed to load resource
or something similar.So I cannot anymore recognize different type of HTTP errors and react accordingly.
Am I missing something new introduced in the
4.0.0-RC0
? I really need this kind of information, so the moment I'll stick to the3.8.0
or eventually switch to another library.Glide load line /
GlideModule
(if any) / list Adapter code (if any):The text was updated successfully, but these errors were encountered: