Handle all unexpected errors

pull/147/head
M66B 6 years ago
parent 3f93a999fa
commit f14de224aa

@ -123,6 +123,11 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
.putExtra("folder", folder.id) .putExtra("folder", folder.id)
.putExtra("outgoing", folder.isOutgoing())); .putExtra("outgoing", folder.isOutgoing()));
} }
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args); }.load(context, owner, args);
} else { } else {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -144,6 +149,11 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
.putExtra("thread", message.thread) .putExtra("thread", message.thread)
.putExtra("id", message.id)); .putExtra("id", message.id));
} }
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args); }.load(context, owner, args);
} }
} }

@ -243,6 +243,11 @@ public class FragmentMessages extends FragmentEx {
Snackbar.make(view, R.string.title_sync_queued, Snackbar.LENGTH_LONG).show(); Snackbar.make(view, R.string.title_sync_queued, Snackbar.LENGTH_LONG).show();
} }
} }
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args); }.load(FragmentMessages.this, args);
} }
}); });
@ -1813,7 +1818,7 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
super.onException(args, ex); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} }
}.load(FragmentMessages.this, args); }.load(FragmentMessages.this, args);
} }

@ -148,6 +148,11 @@ public class FragmentOperations extends FragmentEx {
} }
return null; return null;
} }
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentOperations.this, new Bundle()); }.load(FragmentOperations.this, new Bundle());
} }
}) })

@ -454,6 +454,11 @@ public class FragmentSetup extends FragmentEx {
EntityOperation.sync(db, folder.id); EntityOperation.sync(db, folder.id);
return null; return null;
} }
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentSetup.this, new Bundle()); }.load(FragmentSetup.this, new Bundle());
} }

@ -162,16 +162,12 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
} }
} }
protected T onLoad(Context context, Bundle args) throws Throwable { protected abstract T onLoad(Context context, Bundle args) throws Throwable;
// Be careful not to access members in outer scopes
return null;
}
protected void onLoaded(Bundle args, T data) { protected void onLoaded(Bundle args, T data) {
} }
protected void onException(Bundle args, Throwable ex) { protected abstract void onException(Bundle args, Throwable ex);
}
private static class Result { private static class Result {
Throwable ex; Throwable ex;

Loading…
Cancel
Save