Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

369
Views
RXJS Custom catcherror operator

Normally I would be able to define a custom operator and structure a pipe like this:

public custOperator = () => {
    return (source: Observable<any>) => {
        return source.pipe(
            map(val => {
                //do stuff with val
            })
        )
    }
};

test(){

    of().pipe(
        this.custOperator(),
        catchError(err => {
            //do stuff with err (more logic will go in here)
            throw err
        })
    ).subscribe()
}

However it's getting tedious writing the catcherror logic every time I need to pipe an observable.

How would I go about creating a similar operator except that it expects an error instead of an observable, such that it mimics catchError?

Update

I was able to create a custom catcherror operator as such:

private customCatchOperator = () => {
    return catchError(err => {
        // handle error 
    })
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can do it as follows:

customCatchOperator() {
   return catchError(err => {
            // handle error
        })
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!