How to use the catchError function from rxjs

Find comprehensive JavaScript rxjs.catchError code examples handpicked from public code repositorys.

39
40
41
42
43
44
45
46
47
48
        else if (stream === 'stdout')
            log.debug(msg(`stdout\n${value}`))
        else if (stream === 'stderr')
            log.warn(msg(`stderr\n${value}`))
    }),
    catchError(error => {
        log.error(msg(error))
        return throwError(() => new Error(`Failed to ${description}.`))
    })
)
fork icon45
star icon180
watch icon34

113
114
115
116
117
118
119
120
121
122
        log.debug(() => `${method} ${url} - ${status} (${ms}ms)`)
    }
})
return request$.pipe(
    map(response => validateResponse(response, validStatuses)),
    catchError(e => {
        if (validStatuses && validStatuses.includes(e.statusCode)) {
            return of(e)
        } else {
            return throwError(() => e)
fork icon45
star icon178
watch icon34

107
108
109
110
111
112
113
114
115
116
        ? taskCompleted$(task.id)
        : progress.state === 'CANCELED'
            ? taskCanceled$(task.id)
            : of(progress)
),
catchError(error =>
    taskFailed$(task.id, error)
),
// Prevent progress notification to Sepal more often than MIN_TIME_BETWEEN_NOTIFICATIONS millis
// This is to prevent flooding Sepal with too many updates
fork icon45
star icon177
watch icon0

+ 2 other calls in file

148
149
150
151
152
153
154
155
156
157
            : exec$(
                path,
                'sudo',
                ['GIT_TERMINAL_PROMPT=0', 'git', 'checkout', '-t', `origin/${branch}`]
            )),
    catchError(() => {
        log.warn(`Failed to checkout branch ${branch}: ${path}`)
        return of(false)
    })
)
fork icon45
star icon0
watch icon0

+ 5 other calls in file

106
107
108
109
110
111
112
113
114
115
return from(RoasFacebook({ user_id }).ad.get_from_db({ ad_id })).pipe(
    concatMap(identity),
    rxfilter((ad) => !isEmpty(ad)),
    rxmap(Facebook.ad.details),
    defaultIfEmpty({}),
    catchError((error) => {
        console.log("Facebook:ad:db:get:error");
        console.log(error);
        return rxof({ ad_id, error: true });
    })
fork icon0
star icon0
watch icon1

+ 5 other calls in file