A simple solution for handling Firestore error.

Alex Mamo
Firebase Tips & Tricks

--

That’s by far the most common and annoying error that you can get when you try to perform a Query against a Cloud Firestore database for reading data, or when you try to create/update/delete Firestore documents. So I’m trying to show you in this article, a few solutions that can help you get rid of this error.

First of all, let’s understand what this error actually represents. Generally, when we interact with Firebase products, and something goes wrong, a FirebaseException will be thrown. When it comes in particular to Cloud Firestore, when something fails, there is a specific exception that is thrown which is called FirebaseFirestoreException. So according to the official documentation, this is:

  • A class of exceptions thrown by Cloud Firestore.

Since when interacting with Firestore there can be potentially multiple reasons why an operation can fail, there should be a way we can differentiate them. That’s the reason why the Firebase team has created a different “status code” for each type of Exception. All these codes are present in an enum that is nested under the FirebaseFirestoreException class that is called Code. There are 17 enum values, for each…

--

--