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

Handling network exceptions (Android) #195

Open
ncruces opened this Issue Nov 17, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@ncruces

ncruces commented Nov 17, 2015

A request that fails on Android (due to a network error) is currently throwing a Java.Net.IOException, which (in Xamarin.Android) inherits directly from System.Exception.

This is unfortunate because the only way of dealing with this in a PCL is to catch every possible System.Exception, and use reflection from there (or IoC) since you obviously can't use the Java.* classes in a PCL.

I don't suggest ModernHttpClient marshals every exception, but maybe it makes sense to catch all Java.Lang.IOException here and marshal them into System.Net.WebException.
#153 seems related.

Don't know about iOS?

@paulhickman-a365

This comment has been minimized.

Show comment
Hide comment
@paulhickman-a365

paulhickman-a365 Nov 26, 2015

I get this problem when using a Wi-Fi network that requires you to login in the browser before being able to reach internet hosts, and I am connected to Wi-Fi but not logged in. A Java.Net.ConnectionException occurs which derives from Java.Net.IOException.

paulhickman-a365 commented Nov 26, 2015

I get this problem when using a Wi-Fi network that requires you to login in the browser before being able to reach internet hosts, and I am connected to Wi-Fi but not logged in. A Java.Net.ConnectionException occurs which derives from Java.Net.IOException.

@viniciusmelquiades

This comment has been minimized.

Show comment
Hide comment
@viniciusmelquiades

viniciusmelquiades Jul 7, 2016

I know this issue seems old, but someone already made a Pull Request to fix this. See #116

Since the merge request itself is old, and the project seems somewhat abandoned, I fixed the issue, based on the merge request I mentioned, with the following class, https://gist.github.com/viniciusmelquiades/629fe226bf7fa8564fd0de2aab85b446

viniciusmelquiades commented Jul 7, 2016

I know this issue seems old, but someone already made a Pull Request to fix this. See #116

Since the merge request itself is old, and the project seems somewhat abandoned, I fixed the issue, based on the merge request I mentioned, with the following class, https://gist.github.com/viniciusmelquiades/629fe226bf7fa8564fd0de2aab85b446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment