Angular 2 Integration

The architecture of Angular 2 is totally different from Angular 1. So you need to follow different methods to capture errors from Angular 2 apps.

1. Custom error handler

You need to create separate error handler to notify errors to Atatus.

// /app/atatus.handler.ts
import { ErrorHandler } from '@angular/core';
declare var atatus: any;

class AtatusErrorHandler implements ErrorHandler {
  handleError(error:any) : void {
    if (atatus) {
      // Send the error to Atatus
      atatus.notify(error.originalError || error);
    }
  }
}

export default AtatusErrorHandler;

2. Use AtatusErrorHandler

Add the custom error handler AtatusErrorHandler in the providers section of @NgModule

// /app/app.module.ts
import { ErrorHandler } from '@angular/core';
import { AppComponent } from './app.component';
import AtatusErrorHandler from './atatus.handler';

@NgModule({
    bootstrap: [AppComponent],
    declarations: [AppComponent],
    providers: [{provide: ErrorHandler, useClass: AtatusErrorHandler}]
})

export class AppModule { }
Document Sections