From 49dba1b9b29664828200d24d4995aceafaa7e279 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 18 Aug 2020 08:20:23 +0200 Subject: [PATCH] Try original exception after retrying with username --- .../eu/faircode/email/FragmentQuickSetup.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java index 6aee3fa46a..30f770a6aa 100644 --- a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java @@ -318,18 +318,22 @@ public class FragmentQuickSetup extends FragmentBase { throw ex; } catch (Throwable ex) { // Why not AuthenticationFailedException? - // Some providers refuse connection with an invalid username - if (!user.equals(username)) { - Log.w(ex); - user = username; - Log.i("Retry with user=" + user); - iservice.connect( - provider.imap.host, provider.imap.port, - EmailService.AUTH_TYPE_PASSWORD, null, - user, password, - null, null); - } else + // Some providers terminate the connection with an invalid username + if (user.equals(username)) throw ex; + else + try { + user = username; + Log.i("Retry with user=" + user); + iservice.connect( + provider.imap.host, provider.imap.port, + EmailService.AUTH_TYPE_PASSWORD, null, + user, password, + null, null); + } catch (Throwable ex1) { + Log.w(ex1); + throw ex; + } } folders = iservice.getFolders();