# Http Error handeling

**URL:** <https://forum.codewithmosh.com/t/http-error-handeling/9397>\
**Category:** Angular\
**Created:** [December 23, 2021, 7:03pm UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397 "2021-12-23T19:03:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharomin](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sharomin](https://forum.codewithmosh.com/u/sharomin)\
**Post date:** [December 23, 2021, 7:03pm UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/1 "2021-12-23T19:03:22Z")

</div>

I have a problem with error handling part of http section, is there any update for this part of Course ?

same problem :  
When importing ‘rxjs/add/operator/catch’ the catch method doesnt appear.  
How can I solve it?

Another problem in this section:  
When adding (error: Responce) to deletePost method ( in posts.component.ts ) .subscribe declaration marks as deprecated.

---

<div class="post-metadata">

**Author:** ![jaykay](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jaykay](https://forum.codewithmosh.com/u/jaykay)\
**Post date:** [December 28, 2021, 1:47pm UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/2 "2021-12-28T13:47:14Z")

</div>

yeah i’m kinda stuck here as well

---

<div class="post-metadata">

**Author:** ![TinMan](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@TinMan](https://forum.codewithmosh.com/u/TinMan)\
**Post date:** [February 18, 2022, 2:39am UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/3 "2022-02-18T02:39:52Z")

</div>

In newer versions of Angular catch has been replaced with catchError, otherwise you can use rxjs-compat to use those older methods. A bit of refactoring was required to get error handling functioning similarly to how Mosh has it due to updates in Angular and Typescript which can easily be found by googling. Regarding the deprecated issue, I believe this is more of a TSLint issue [Deprecation warning on a complete callback without any complete callback · Issue #6060 · ReactiveX/rxjs · GitHub](https://github.com/ReactiveX/rxjs/issues/6060)

---

<div class="post-metadata">

**Author:** ![pg2](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@pg2](https://forum.codewithmosh.com/u/pg2)\
**Post date:** [May 31, 2022, 8:44am UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/4 "2022-05-31T08:44:47Z")

</div>

Hi

I got stuck here too.

Below is the code that worked for me. I might help others too.

```auto
 delete(id: any) {
        return this.http.delete(this.url + '/' + id)
            .pipe(
                catchError(this.handleError)
            );
    }

```

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [June 2, 2022, 6:52am UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/5 "2022-06-02T06:52:22Z")

</div>

There used to be a migration guide on the GitHub page for RxJS. Here’s a link to the state of it at least at one point in time: [rxjs/migration.md at 2afd869816f77ef7a154b4db5dd1fbffd382339e · ReactiveX/rxjs · GitHub](https://github.com/ReactiveX/rxjs/blob/2afd869816f77ef7a154b4db5dd1fbffd382339e/docs_app/content/guide/v6/migration.md)

[This page](https://github.com/ReactiveX/rxjs/blob/91088dae1df097be2370c73300ffa11b27fd0100/doc/pipeable-operators.md) goes into even more details.

For the most part, you now use the `pipe` function which takes an array of “Pipeable Operators” like `map`, `filter` and `catchError` (you can read more about those [here](https://rxjs.dev/guide/operators#what-are-operators) and the rest of that page has more details about pipes in general).

Two of the main translations we need to use are:

```auto
// Before
someObservable.catch(...)
// Now
someObservable.pipe(catchError(...))

// Before
anotherObservable.map(...)
// Now
anotherObservable.pipe(map(...))

```

---

<div class="post-metadata">

**Author:** ![mojeffcodes](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mojeffcodes](https://forum.codewithmosh.com/u/mojeffcodes)\
**Post date:** [February 1, 2023, 10:47pm UTC](https://forum.codewithmosh.com/t/http-error-handeling/9397/6 "2023-02-01T22:47:17Z")

</div>

Here’s another thread with working examples.

> [@Throwing Application-specific Errors .catch](https://forum.codewithmosh.com/t/throwing-application-specific-errors-catch/505/5):
>
> private handleError(error: Response) { if (error.status === 400) return throwError(new BadInput(error.json())); if (error.status === 404) return throwError(new NotFoundError()); return throwError(new AppError(error.json())); }
