Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

370
Vistas
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 Respuestas
Responde la pregunta

0

You can do it as follows:

customCatchOperator() {
   return catchError(err => {
            // handle error
        })
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda