yigit/dev-summit-architecture-demo

Failed FeedFetchJob Event?

jam01 opened this issue · 1 comments

jam01 commented

I'm having a little trouble finding where a failed fetch is handled, maybe I'm just missing it.

Here's where the activity checks for success:
public void onEventMainThread(FetchedFeedEvent event) {
if (event.isSuccess()) {
refresh(event.getOldest());
} else {
Snackbar.make(mBinding.coordinatorLayout,
R.string.cannot_refresh_feed, Snackbar.LENGTH_SHORT).show();
}

And here's where the job performs the call :
public void onRun() throws Throwable {
Response response = feed.execute();
if (response.isSuccess()) {
Post oldest = handleResponse(response.body());
mEventBus.post(new FetchedFeedEvent(true, mUserId, oldest));
} else {
throw new NetworkException(response.code());
}
}

The exception is thrown but I can't find where it's caught and translated to a failed FetchedFeedEvent.

jam01 commented

Never mind, found it in com.path.android.jobqueue.BaseJob

/**
* if {@code onRun} method throws an exception, this method is called.
* return true if you want to run your job again, return false if you want to dismiss it. If you return false,
* onCancel will be called.
*/
abstract protected boolean shouldReRunOnThrowable(Throwable throwable);