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

704
Views
Catching Error in pipe() method of an Observable - rxjs/Axios

I refactored my http layer to go from a promised-based implementation to observables using rxjs. The problem that I am facing is that the code crashes whenever server response is 400 or 500,

Axios.request(config).pipe(map(((response: AxiosResponse) => response), catchError(e => {
    return new Observable(e);
})));

The problem I am facing is that the error is not being handled by the catchError callback. I am looking for a way in which the error is handled by the catchError callback so that the response can be handled gracefully.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I don't know your problem is this but you can do this:

import { EMPTY } from 'rxjs';

Axios.request(config).pipe(map(((response: AxiosResponse) => response), 
catchError(() => EMPTY)));

EMPTY is an object that is imported from rxjs libaray.

about 4 years ago · Juan Pablo Isaza Report

0

It looks like you want to turn the error notification to next notification so you need to use return of(e) eventually EMPTY if you want to suppress the error.

new Observable(e) is probably what throws the error in your case because the parameter passed to Observable needs to be a function which e is not in this case.

about 4 years ago · Juan Pablo Isaza 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!