angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Errors from methods returning a Promise are not bubbling up when Promise is converted to Observable

Open chan-dev opened this issue 1 year ago • 2 comments
trafficstars

In order to achieve consistency, i want to convert methods returning Promises to Observable. However, errors are ignored when trying to catch the error either from the method or from the caller of the method.

See the code below.

createList(newList: NewListDTO) {
    const collectionRef = collection(this.db, `lists`);

    const newListDoc = addDoc(collectionRef, {
      name: newList.name,
      uid: newList.uid,
      created_at: serverTimestamp(),
    });

    // return defer(async () => {
    //   return await newListDoc;
    // });

    return scheduled(newListDoc, asyncScheduler).pipe(
      // FIXME: error is not being caught from firstore addDoc
      catchError((err) => {
        return throwError(() => err);
      }),
    );
  }

chan-dev avatar Dec 14 '23 01:12 chan-dev

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Dec 14 '23 01:12 google-oss-bot

Have your tried using of or from from rxjs.

Sapython avatar Dec 22 '23 14:12 Sapython