Как мне поймать и сделать мое приложение устойчивым к ошибкам десериализации в firestore?
Это мой кусок кода:
db.collection("ABC").whereEqualTo("some_enabled",true)
.orderBy("index_abc", Query.Direction.DESCENDING).limit(100)
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot snapshots, FirebaseFirestoreException e) {
if (e != null) {
return;
}
List<User> someList = new ArrayList<>();
for (QueryDocumentSnapshot doc : snapshots) {
someList.add(doc.toObject(User.class)); // deserialization error here
}
if(Fragment.this.getActivity() != null)
{
someAdapter = new UserGridAdapter(someList,mCurrentUser, Fragment.this.getActivity());
someRecyclerView.setAdapter(someAdapter);
someAdapter.notifyDataSetChanged();
}
}
});
Вот ошибка:
java .lang.RuntimeException: на com.google.firebase.firestore.util.CustomClassMapper.deserializeError (com.google.firebase: firebase-firestore @@ 21.1.1: 563) на com.google. firebase.firestore.util.CustomClassMapper.convertInteger (com.google.firebase: firebase-firestore @@ 21.1.1: 411) на com.google.firebase.firestore.util.CustomClassMapper.deserializeToPrimitive (com.google.firebase: firebase- firestore @@ 21.1.1: 320) на com.google.firebase.firestore.util.CustomClassMapper.deserializeToClass (com.google.firebase: firebase-firestore @@ 21.1.1: 226) на com.google.firebase.firestore. util.CustomClassMapper.deserializeToType (com.google.firebase: firebase-firestore @@ 21.1.1: 189) по адресу com.google.firebase.firestore.util.CustomClassMapper.access $ 300 (com.google.firebase: firebase-firestore @@ 21.1.1: 54) на com.google.firebase.firestore.uti l.CustomClassMapper $ BeanMapper.deserialize (com.google.firebase: firebase-firestore @@ 21.1.1: 770) по адресу com.google.firebase.firestore.util.CustomClassMapper $ BeanMapper.deserialize (com.google.firebase: firebase- firestore @@ 21.1.1: 741) на com.google.firebase.firestore.util.CustomClassMapper.convertBean (com.google.firebase: firebase-firestore @@ 21.1.1: 542) на com.google.firebase.firestore. util.CustomClassMapper.deserializeToClass (com.google.firebase: firebase-firestore @@ 21.1.1: 253) по адресу com.google.firebase.firestore.util.CustomClassMapper.convertToCustomClass (com.google.firebase: firebase-firestore @@ 21.1 .1: 100) на com.google.firebase.firestore.DocumentSnapshot.toObject (com.google.firebase: firebase-firestore @@ 21.1.1: 210) на com.google.firebase.firestore.DocumentSnapshot.toObject (com. google.firebase: firebase-firestore @@ 21.1.1: 188) по адресу xyz.app.zin go .zingoapp.HomeScreen.Fragments.DiscoverFragment $ 1.onEvent (DiscoverFragment. java: 103) по адресу xyz.app.zin go .zingoapp.HomeScreen.Fragments.DiscoverFragment $ 1.onEvent (DiscoverFragment. java: 100)