Typically, I have the capability to define a personalized operator and structure a pipe in this manner:
public customOperator = () => {
return (source: Observable<any>) => {
return source.pipe(
map(val => {
// manipulate val
})
)
}
};
test(){
of().pipe(
this.customOperator(),
catchError(err => {
// handle error (more operations will be added here)
throw err
})
).subscribe()
}
However, it has become monotonous to write the catchError logic repeatedly whenever I need to pipe an observable.
Is there a way for me to devise a similar operator that anticipates an error instead of an observable, resembling catchError?
Update
I succeeded in devising a customized catcherror operator like so:
private customCatchOperator = () => {
return catchError(err => {
// process error
})
}