[英]Angular2 ErrorHandler, error breaks the code
import { Injectable, ErrorHandler, Inject, Injector } from '@angular/core';
import { MessengerService } from '../services';
import { MessageTypeEnum } from '../../shared';
@Injectable()
export class AppErrorHandler extends ErrorHandler {
constructor(private messengerService: MessengerService) {
super(true);
}
handleError(error) {
console.log('ERROR!');
console.log(error);
this.messengerService.showMessage('Nastala chyba', 'Předem se omlouváme za vzniklé potíže', MessageTypeEnum.Error);
}
}
日志記錄有效,但是該應用程序仍然崩潰,並且日志記錄也跟蹤http錯誤,但是我想實現一個目標,即會記錄每個錯誤,但其他角度的應用程序將正常運行。
錯誤示例:value.getMonth不是ViewWrappedError.ZoneAwareError上的函數或404,500個http錯誤
只是不拋出錯誤。
constructor(private messengerService: MessengerService) {
super(true);
}
你需要在這里放假
super(false);
文檔: https : //angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html
來源: https : //github.com/angular/angular/blob/master/modules/%40angular/core/src/error_handler.ts
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.