Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@btapai/ng-error-handler
Advanced tools
Install the package with the following script:
npm install @btapai/ng-error-handler --save
This package has @angular/cdk as a peer dependency. Install it as well:
npm install @angular/cdk --save
If your project does not use @angular/material, add the following line into your styles.css file:
@import '~@angular/cdk/overlay-prebuilt.css';
Import the module into your main ngModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ErrorHandlerModule } from '@btapai/ng-error-handler';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
ErrorHandlerModule.forRoot(), // place it into the imports array
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
With this setup uncaught errors will be handled by this error-handler module.
This packages uses the Angular CDK Overlay module for creating a backdrop. If you would like to style the overlay, provide a configuration object with your custom OverlayConfig object. For possible config options check out its documentation
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ErrorHandlerModule, ERROR_HANDLER_CONFIG, ErrorHandlerConfig } from '@btapai/ng-error-handler';
const CustomErrorHandlerConfig: ErrorHandlerConfig = {
overlayConfig: {
hasBackdrop: false, //
},
};
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, ErrorHandlerModule.forRoot()],
providers: [{ provide: ERROR_HANDLER_CONFIG, useValue: CustomErrorHandlerConfig }],
bootstrap: [AppComponent],
})
export class AppModule {}
You can also provide custom hooks to run when an error is thrown:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ErrorHandlerModule, ERROR_HANDLER_CONFIG, ErrorHandlerConfig } from '@btapai/ng-error-handler';
import { ThirdPartyErrorLogger } from 'third-party-error-logger';
const CustomErrorHandlerConfig: ErrorHandlerConfig = {
errorHandlerHooks: [ThirdPartyErrorLogger.logErrorMessage],
};
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, ErrorHandlerModule.forRoot()],
providers: [{ provide: ERROR_HANDLER_CONFIG, useValue: CustomErrorHandlerConfig }],
bootstrap: [AppComponent],
})
export class AppModule {}
I'd like to keep this module up-to date with Angular versions.
FAQs
An error handler library for angular applications
We found that @btapai/ng-error-handler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.