1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 21:24:34 +00:00

Improved error handling

This commit is contained in:
M66B 2018-12-21 11:17:18 +01:00
parent cb7565fa9e
commit 697659e631
2 changed files with 22 additions and 18 deletions

View file

@ -44,7 +44,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.SystemClock;
import android.preference.PreferenceManager;
@ -1001,16 +1000,17 @@ public class ServiceSynchronize extends LifecycleService {
}
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (FolderClosedException ex) {
throw ex;
} catch (IOException ex) {
if (ex.getCause() instanceof MessageRemovedException)
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
else
throw ex;
throw ex;
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
}
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error();
} finally {
wlAccount.release();
@ -1081,16 +1081,17 @@ public class ServiceSynchronize extends LifecycleService {
}
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (FolderClosedException ex) {
throw ex;
} catch (IOException ex) {
if (ex.getCause() instanceof MessageRemovedException)
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
else
throw ex;
throw ex;
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
}
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account, folder, ex);
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error();
} finally {
wlAccount.release();
@ -2093,10 +2094,11 @@ public class ServiceSynchronize extends LifecycleService {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (FolderClosedException ex) {
throw ex;
} catch (FolderClosedIOException ex) {
} catch (IOException ex) {
throw ex;
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} finally {
db.endTransaction();
// Reduce memory usage

View file

@ -217,13 +217,15 @@ public class ViewModelBrowse extends ViewModel {
count++;
}
db.message().setMessageFound(message.account, message.thread);
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
} catch (FolderClosedException ex) {
throw ex;
} catch (IOException ex) {
throw ex;
} catch (Throwable ex) {
if ((ex instanceof MessageRemovedException) || (ex instanceof FolderClosedException))
Log.w(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
else {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
throw ex;
}
Log.e(Helper.TAG, folder.name + "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
} finally {
((IMAPMessage) isub[j]).invalidateHeaders();
}