Added search error reporting

pull/72/head
M66B 6 years ago
parent 6244a4557e
commit c7fc14111a

@ -572,7 +572,6 @@ public class FragmentAccount extends FragmentEx {
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
} }
}.load(FragmentAccount.this, args); }.load(FragmentAccount.this, args);
} }

@ -362,7 +362,6 @@ public class FragmentIdentity extends FragmentEx {
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
// TODO: recover from error
} }
}.load(FragmentIdentity.this, args); }.load(FragmentIdentity.this, args);
} }

@ -1,9 +1,12 @@
package eu.faircode.email; package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.widget.Toast;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPStore; import com.sun.mail.imap.IMAPStore;
@ -88,6 +91,7 @@ public class SearchDataSource extends PositionalDataSource<TupleMessageEx> imple
callback.onResult(result.messages, params.requestedStartPosition, result.total); callback.onResult(result.messages, params.requestedStartPosition, result.total);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
reportError(ex);
} }
} }
@ -99,6 +103,7 @@ public class SearchDataSource extends PositionalDataSource<TupleMessageEx> imple
callback.onResult(result.messages); callback.onResult(result.messages);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
reportError(ex);
} }
} }
@ -205,6 +210,15 @@ public class SearchDataSource extends PositionalDataSource<TupleMessageEx> imple
return result; return result;
} }
private void reportError(final Throwable ex) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(context, Helper.formatThrowable(ex), Toast.LENGTH_LONG).show();
}
});
}
private class SearchResult { private class SearchResult {
int total; int total;
List<TupleMessageEx> messages; List<TupleMessageEx> messages;

Loading…
Cancel
Save