# a4-http-error-interceptor

> Intercept http error globally and handle the error gracefully

Latest version **9.0.0** (published 2020-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install a4-http-error-interceptor
pnpm add a4-http-error-interceptor
yarn add a4-http-error-interceptor
bun add a4-http-error-interceptor
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 9.0.0 |
| Published | 2020-02-08 |
| First published | 2017-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 106.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Bill Cheng |
| Maintainers | cccheng |
| Keywords | angular, http, error |

## Links

- npm: https://www.npmjs.com/package/a4-http-error-interceptor
- npm.io page: https://npm.io/package/a4-http-error-interceptor

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 9.0.0 (latest) — 2020-02-08
- 8.0.0 — 2019-05-29
- 7.1.0 — 2018-12-24
- 7.0.0 — 2018-10-19
- 6.0.3 — 2018-05-20
- 6.0.2 — 2018-05-19
- 5.0.1 — 2017-11-02
- 5.0.0 — 2017-11-02
- 0.0.1 — 2017-09-16

## README

# a4-http-error-interceptor
Angular 7 Http Error Interceptor

# How-To
## Install
```
npm install a4-http-error-interceptor
```

## app.module.ts
1. Add ```HttpErrorModule``` to imports of the ```app.module.ts```.

```typescript

...
import { HttpErrorModule } from 'a4-http-error-interceptor';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    HttpErrorModule,
    ...
  ],
  ...
})
```

## Inject the service
```typescript
constructor(private httpErrorService: HttpErrorService) { }
```

## Push error handler during ngOnInit
```typescript
this.httpErrorService.push(404, () => {
  // handle 404
  });
);

this.httpErrorService.push('*', () => {
  // handle all other HTTP Errors
  });
);

```

## Pop error handler during ngOnDestroy
```typescript
this.httpErrorService.pop(404);
```

---
_Source: https://npm.io/package/a4-http-error-interceptor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
