Socket
Book a DemoInstallSign in
Socket

a4-http-error-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a4-http-error-interceptor

Intercept http error globally and handle the error gracefully

9.0.0
latest
npmnpm
Version published
Weekly downloads
11
-45%
Maintainers
1
Weekly downloads
 
Created
Source

a4-http-error-interceptor

Angular 7 Http Error Interceptor

How-To

Install

npm install a4-http-error-interceptor

app.module.ts

  • Add HttpErrorModule to imports of the app.module.ts.

...
import { HttpErrorModule } from 'a4-http-error-interceptor';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    HttpErrorModule,
    ...
  ],
  ...
})

Inject the service

constructor(private httpErrorService: HttpErrorService) { }

Push error handler during ngOnInit

this.httpErrorService.push(404, () => {
  // handle 404
  });
);

this.httpErrorService.push('*', () => {
  // handle all other HTTP Errors
  });
);

Pop error handler during ngOnDestroy

this.httpErrorService.pop(404);

Keywords

angular

FAQs

Package last updated on 08 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.