AddDoc error not being caught
- Vorherrschende Sprache
- TypeScript
- Sterne
- 7.8k
- Forks
- 2.2k
- Ø Merge
- 22 Std. 28 Min.
- Gemergte PRs (30 T.)
- 6
Beschreibung
Good morning.
In our project, I've been trying to handle the output of an addDoc call using angular/fire. The exception will get caught but not the error thrown by addDoc. When uncommenting the line //throw "patata" the catch block will get executed.
```
async saveProjectTest(projectTracking: ProjectTracking) {
const projectTrackingsRef = collection(this.firestore, 'projecttrackings');
try{
console.log("here1");
//throw "patata";
await addDoc(projectTrackingsRef, projectTracking);
console.log("here2");
}catch(error){
console.log("caught");
};
}
```
I don't know if it is a bug or what it is, but this is specially important since it seems like the appropriate way to handle connection errors and any other kinds of errors in my app. Right now I can only implement the "happy path".
I'm using Chromium v130, angularfire 18.0.1, with Angular 18.1.3, connecting to a docker container running a firebase emulator. When I want to test no connectivity, I take down the firebase container.
Thanks in advance, appreciate your help.
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit dem saveProjectTest-Einstiegspunkt und seinem await addDoc-Aufruf unter Verwendung der angegebenen AngularFire- und Firestore-Emulator-Versionen. Reproduzieren Sie den Fall bei angehaltenem Firebase-Container, vergleichen Sie den addDoc-Fehler mit dem expliziten throw und überprüfen Sie, ob der erwartete Fehler den catch-Block erreicht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, firebase, typescript
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100