1

I want to be able to respond to errors from a call to collectionData. I added a catchError but it never gets called. In fact, the collectionData emits a result with no elements.

export const bundleEpic = action$ => action$.pipe(
  ofType(BUNDLES_LOAD),
  tap(action => console.log(`Received action: type=${action.type}`)),
  switchMap(() => (
    collectionData(bundlesRef, 'id')
    .pipe(
      tap(docs => console.log(`bundleEpic: size = ${docs.length}`)),
      map(docs => publicBundlesLoadSuccess(docs)),
      catchError(error => from(publicBundlesLoadFail(error))
    )
  ))
)

What is the proper way to handle errors using collectionData?

ggradnig
  • 13,119
  • 2
  • 37
  • 61
Duane
  • 273
  • 1
  • 11

1 Answers1

2

catchError will catch errors returned by the observable. In your case that is collectionData. I'm not familiar with RxFire but if you say that collectionData emits a result with no elements then it makes sense for catchError to not be called. Empty results is still considered a (successful) result. Try making collectionData fail on purpose to see if you'll get an error in catchError.

Dzhavat Ushev
  • 725
  • 4
  • 13