import { Component } from '@angular/core' ; import Bugsnag from '@bugsnag/js' ; @ Component ( { selector : 'app-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent { title = 'app' ; doARenderError = false ; doAHandledError = false ; triggerUnhandledError ( ) { throw new Error ( 'Oh no' ) ; } triggerHandledError ( ) { this . doAHandledError = true ; try { var niceCode = "Everything is fine here." ; throw ( "Bad thing!" ) ; } catch ( e ) { Bugsnag . notify ( e , function ( event ) { event . context = 'Don\'t worry - I handled it!' ; } ) ; } setTimeout ( function ( ) { this . doAHandledError = false ; } . bind ( this ) , 1000 ) ; } triggerRenderError ( ) { this . doARenderError = true ; setTimeout ( function ( ) { this . doARenderError = false ; } . bind ( this ) , 1000 ) ; } }