0

I have this simple query.

async function getUsers() {
  const c = collection(db, "exampleCollection")
  getDocs(c).then(querySnapshot => {
    console.log(`Snapshot: ${querySnapshot}`)
    querySnapshot.forEach((doc) => {
      const data = doc.data()
      console.log(`User: ${doc.id} => ${data.name}`)
    });
  })
    .catch(err => {
      // THIS NEVER GETS HIT
      console.error(err)
    })

}

Sometimes I don't have the local emulator fired up and I can see in the browser console an error.

build.umd.js:3103 [2022-09-12T20:19:17.950Z]  @firebase/firestore: Firestore (9.9.4): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

The errors aren't actually thrown but it appears to be caught by the firestore framework and logged to the console automatically.

My questions is, how do I receive those errors in code to report in my other error logging tools if they aren't thrown? Is there a configuration or something that I can set?

0 Answers0