I´m trying to implement a central ExceptionHandler in Angular 2. I searched in SO and found several topics about this subject, like those bellow:
Module '"angular2/angular2"' has no exported member 'ExceptionHandler'
How to properly overwrite the exceptionHandler in angularjs?
But, this topics seem to be outdated.
I´m using Angular 2 RC5, and following the documentation here, I tried to implement:
import { ExceptionHandler } from '@angular/core';
export class CustomExceptionHandler implements ExceptionHandler {
call(error:any, stackTrace:any = null, reason:string = null) {
// do something with the exception
}
}
But I received a error like that "TS2420 - CustomExceptionHandler incorrectly implements interface ExceptionHandler. Property '_logger' is missing in type 'CustomExceptionHandler'.
I´am a newbie in TS, but I have been programming in Java for 10 years.
Actually, when I click on ExceptionHandler in IDE (IntelliJ), the code follow up to a class, not a interface.
export declare class ExceptionHandler {
private _logger;
private _rethrowException;
constructor(_logger: any, _rethrowException?: boolean);
static exceptionToString(exception: any, stackTrace?: any, reason?: string): string;
call(exception: any, stackTrace?: any, reason?: string): void;
}