Skip to content
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
Open

Handling network exceptions (Android) #195

ncruces opened this issue Nov 17, 2015 · 2 comments

Comments

@ncruces
Copy link

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
Copy link

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.

@viniciussalvati
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants