Unknown host exception because of VPN

This commit is contained in:
M66B 2023-11-02 13:19:42 +01:00
parent e2db6d9943
commit 6c2b2ae45a
1 changed files with 6 additions and 2 deletions

View File

@ -612,7 +612,7 @@ public class EmailService implements AutoCloseable {
} catch (UnknownHostException ex) {
String last = prefs.getString(key, null);
if (TextUtils.isEmpty(last))
throw new MessagingException(ex.getMessage(), ex);
throw ex;
else {
EntityLog.log(context, EntityLog.Type.Network, "Using " + key + "=" + last);
main = InetAddress.getByName(last);
@ -641,7 +641,11 @@ public class EmailService implements AutoCloseable {
} catch (UnknownHostException ex) {
crumb.put("exception", ex + "\n" + android.util.Log.getStackTraceString(ex));
Log.breadcrumb("Connection failed", crumb);
throw new MessagingException(ex.getMessage(), ex);
if (ConnectionHelper.vpnActive(context))
throw new MessagingException(ex.getMessage(),
new Exception(context.getString(R.string.title_service_vpn), ex));
else
throw new MessagingException(ex.getMessage(), ex);
} catch (MessagingException ex) {
crumb.put("exception", ex + "\n" + android.util.Log.getStackTraceString(ex));
Log.breadcrumb("Connection failed", crumb);