Catch search exceptions

pull/147/head
M66B 6 years ago
parent 0bbf4d38d2
commit 71e484c1c3

@ -25,7 +25,6 @@ import android.util.Log;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.IMAPStore; import com.sun.mail.imap.IMAPStore;
import com.sun.mail.util.FolderClosedIOException;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -133,6 +132,7 @@ public class ViewModelBrowse extends ViewModel {
EntityAccount account = db.account().getAccount(folder.account); EntityAccount account = db.account().getAccount(folder.account);
try {
Properties props = MessageHelper.getSessionProperties(account.auth_type, account.insecure); Properties props = MessageHelper.getSessionProperties(account.auth_type, account.insecure);
props.setProperty("mail.imap.throwsearchexception", "true"); props.setProperty("mail.imap.throwsearchexception", "true");
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
@ -167,6 +167,14 @@ public class ViewModelBrowse extends ViewModel {
Log.i(Helper.TAG, "Boundary found messages=" + state.imessages.length); Log.i(Helper.TAG, "Boundary found messages=" + state.imessages.length);
state.index = state.imessages.length - 1; state.index = state.imessages.length - 1;
} catch (Throwable ex) {
if (ex instanceof FolderClosedException)
Log.w(Helper.TAG, "Search " + ex + "\n" + Log.getStackTraceString(ex));
else {
Log.e(Helper.TAG, "Search " + ex + "\n" + Log.getStackTraceString(ex));
throw ex;
}
}
} }
int count = 0; int count = 0;
@ -202,9 +210,7 @@ public class ViewModelBrowse extends ViewModel {
} }
db.message().setMessageFound(message.account, message.thread); db.message().setMessageFound(message.account, message.thread);
} catch (Throwable ex) { } catch (Throwable ex) {
if ((ex instanceof MessageRemovedException) || if ((ex instanceof MessageRemovedException) || (ex instanceof FolderClosedException))
(ex instanceof FolderClosedException) ||
(ex instanceof FolderClosedIOException))
Log.w(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.w(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
else { else {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));

Loading…
Cancel
Save