import { ErrorHandler , } from '@angular/core' ; export class UncaughtErrorHandler implements ErrorHandler { listeners : Array < ( err : Error ) => void > = [ ] ; addListener ( listener ) { this . listeners . push ( listener ) ; return ( ) => { this . listeners = this . listeners . filter ( l => l !== listener ) ; } ; } handleError ( err ) { this . listeners . forEach ( fn => fn ( err ) ) ; } }