From 6c2b2ae45a2a6e75600df5f6c48e5c3241bf0916 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Nov 2023 13:19:42 +0100 Subject: [PATCH] Unknown host exception because of VPN --- app/src/main/java/eu/faircode/email/EmailService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index 5741ed6de1..3dd953ad4e 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -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);