-
Notifications
You must be signed in to change notification settings - Fork 1.9k
FirestoreDataSource - Please add the ability to get an occurred exception #1592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Zeliret can you show an example of the code you're using now and maybe some comments on how you'd want it to improve? |
@samtstern sure. Thanks for the answer. val options = FirestorePagingOptions.Builder<Trip>()
.setLifecycleOwner(this)
.setQuery(result.data.query, Source.DEFAULT, pagingConfig) {
result.data.converter(it)
}
.build()
binding.tripsList.swapAdapter(TripsAdapter(options), false) Let's assume I get an error while I'm loading a page. I can check it here: override fun onLoadingStateChanged(state: LoadingState) {
if( state == LoadingState.ERROR ) {
retry()
}
} But I can get only the flag. How can I get the actual error? As far as I can see from the source code: /**
* Error listener that logs, sets the error state, and sets up retry.
*/
private abstract class OnLoadFailureListener implements OnFailureListener {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "load:onFailure", e);
// On error we do NOT post any value to the PagedList, we just tell
// the developer that we are now in the error state.
mLoadingState.postValue(LoadingState.ERROR);
// Set the retry action
mRetryRunnable = getRetryRunnable();
}
protected abstract Runnable getRetryRunnable();
} Here the exception just dumped into the log. |
@Zeliret ah I see that's a good feature request! You're right, there's no good way to get it right now in the Paginated adapters. |
How would you feel about something like a |
That sounds good. if( state == LoadingState.ERROR ) {
val ex = getLastError()
if( ex is IOException )
retry()
else
showErrorMessage(ex)
} As for me that should works. Thank you! :) |
Yep that's how I imagine it too. |
We should solve this issue together as same as we implemented in We will override the method as protected void onError(Exception e) {
} ...and will implement as... @Override
protected void onError(@NonNull Exception e) {
mSwipeRefreshLayout.setRefreshing(false);
Log.e(TAG, e.getMessage(), e);
} After this, users will able to get status about caught |
This has been fixed and released in |
Right now I can only get an error status and call retry. But I need to get the exact exception to provide an explanation to my users.
I have found the place where the error state is populated and It seems that I need to override a lot of code to get the error message.
Is there a good way to workaround this?
The text was updated successfully, but these errors were encountered: