2017-04-12 86 views
0

在我們的項目中,我們已經使用了用角多的錯誤處理

{provide: ErrorHandler, useExisting: CustomErrorHandler} 

這CustomErrorHandler由第三方這些錯誤記錄到一箇中央服務器提供的自定義錯誤處理程序。除此之外,我們還想實現我們自己的中央錯誤處理,以便在屏幕上顯示錯誤。

有沒有辦法在角度有多個錯誤處理程序?

+0

裝飾'CustomErrorHandler '用你的邏輯重寫'CustomErrorHandler' – yurzui

回答

1

謝謝@yurzui,任何人loooking代碼這裏是我使用的片段:

AppModule.ts:

{provider: ErrorHandler, useClass: LocalErrorHandler} 

LocalErrorHandler.ts:

export class LocalErrorHandler extends CustomErrorHandler 
{ 
    handleError(error: any) 
    { 
     //Local custom handling 
     super.handleError(error); 
    } 
}