ErrorHandler in Angular2
Ich habe eine Frage zu der neuen Klasse ErrorHandler (war in RC.6 enthalten).
Ich habe ein Beispiel aus offiziellen Dokumenten:https: //angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.htm
import{ErrorHandler} from "@angular/core";
import{NgModule} from "@angular/core";
export class MyErrorHandler implements ErrorHandler {
call(error: any, stackTrace: any = null, reason: any = null) {
// do something with the exception
console.log("do something with the exception");
}
// I handle the given error.
public handleError( error: any ): void {
console.log("I handle the given error");
}
}
@NgModule({
providers: [
{
provide: ErrorHandler,
useClass: MyErrorHandler
}
]
})
export class MyErrorModule {}
Nachdem ich meine app.module-Datei bearbeitet habe
import {MyErrorHandler} from "./error.module";
import {MyErrorModule } from "./error.module";
..
@NgModule({
imports: [
MyErrorModule
....
],
...
providers: [MyErrorHandler]
....
Now MyErrorHandler fängt Fehler ab:
throw new Error("my test error");
Aber es fängt keine http-Fehler wie: "GEThttp: //example.com/rest/use 401 (Unauthorized) ". Kann mir jemand das erklären?
Danke im Voraus