저는 약간의 주위를 검색했는데 혹시 혹서를 극복하는데 도움이되는 것을 발견하지 못했습니다. 필자는 필요에 따라 Angular2 ExceptionHandler를 구현했다고 생각하지만 결코 호출되지 않습니다.Angular2 ExceptionHandler가 작동하지 않습니다.
Main.ts :
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent } from './app.component';
import { ExceptionHandler, Injector , provide, Provider} from '@angular/core';
import { APP_ROUTER_PROVIDERS } from './app.routes'; // <-- load in global routes and bootstrap them
import { ErrorHandler } from './errorhandler/error-handler.component';
bootstrap(AppComponent,[
APP_ROUTER_PROVIDERS,
disableDeprecatedForms(),
provideForms(),
provide(ExceptionHandler, {useClass: ErrorHandler})
])
오류 handler.component.ts : 내가 시험 (내 서비스 중 하나에서 발생하는 강제하고있어 HTTP 오류가
import { Component, Injectable, ExceptionHandler } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
import { APP_PROVIDERS } from '../app.providers';
@Component({
moduleId: module.id,
template: `Error happened here!!!!`,
directives: [ ROUTER_DIRECTIVES ],
providers: [ APP_PROVIDERS ]
})
@Injectable()
export class ErrorHandler extends ExceptionHandler {
call (exception: any, stackTrace?: any, reason?: string): void {
}
}
예외 처리) 내 "전역"처리기가 호출 될 것이라고 예상 할 것이다. 내가 놓친 게 있니? 안타깝게도 지금 당장은 많은 문서가 없습니다 ...
TIA.
제임스