Sawtaytoes
9/30/2018 - 9:15 AM

Handling Generic Errors

This example provides a method for logging errors while also safely continuing when an error does occur.

const storeCurrentUrlEpic = (
  action$,
  state$,
  { ajax },
) => (
  action$
  .pipe(
    ofType(GET_CURRENT_URL),
    map(() => (
      window.location.href
    )),
    map(storeCurrentUrl),
    catchError(error => (
      merge(
        (
          of(
            storeCurrentUrl('')
          )
        ),
        (
          of(
            logError(
              error
            )
          )
        ),
      )
    )),
  )
)