projects/wms-framework/src/lib/baseframework/UnhandledExceptionsFilterService.ts
Default filter service to be used in UnhandledExceptionsHandler to filter which errors should be notified through Application?.Current?.UnhandledException.
This implementation will consider to report any error of type Exception or any error which is not an angular platform error identifed by 'NGXXXX:'
A custom service can be registered to replace this one.
class MyFilterService implements UnhandledExceptionsFilterService {
public shouldBeReported(error: any): boolean {
return <customConditions>
}
}
@NgModule({
providers: [{provide: UnhandledExceptionsFilterService, useClass: MyFilterService}]
})
class MyModule {}
Methods |
|
Public shouldBeReported | ||||||
shouldBeReported(er: any)
|
||||||
Test if an error should be notified
Parameters :
Returns :
boolean
{boolean} |
import { Injectable } from '@angular/core';
/**
* Default filter service to be used in UnhandledExceptionsHandler to filter which errors should
* be notified through Application?.Current?.UnhandledException.
*
* This implementation will consider to report any error of type Exception or any error which is
* not an angular platform error identifed by 'NGXXXX:'
*
* A custom service can be registered to replace this one.
*
* @usageNotes
* ### Example
*
* ```
* class MyFilterService implements UnhandledExceptionsFilterService {
* public shouldBeReported(error: any): boolean {
* return <customConditions>
* }
* }
*
* @NgModule({
* providers: [{provide: UnhandledExceptionsFilterService, useClass: MyFilterService}]
* })
* class MyModule {}
* ```
*
* @export
* @class UnhandledExceptionsFilterService
*/
@Injectable()
export class UnhandledExceptionsFilterService {
/**
* Test if an error should be notified
*
* @param {*} er
* @return {*} {boolean}
* @memberof UnhandledExceptionsFilterService
*/
public shouldBeReported(er: any): boolean {
//Angular exceptions will be ignored
return !!er && !/^\s*NG\d+:/g.test(er?.message);
}
}