[英]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.