projects/wms-framework/src/lib/baseframework/UnhandledExceptionsHandler.ts
Global exception handler to be used to report Exceptions to Application.Current.UnhandledException, the selection of which errors will be reported can be handled through filterService.
Errors will be handled over to the ErrorHandler.handleError too
Methods |
constructor(filterService: UnhandledExceptionsFilterService)
|
||||||||
Creates an instance of UnhandledExceptionsHandler. exceptions must be reported
Parameters :
|
handleError | ||||||
handleError(er: any)
|
||||||
Handles the error
Parameters :
Returns :
void
|
import { ErrorHandler, Injectable } from '@angular/core';
import { Application } from '../basecomponentmodel/Application';
import { smGetExceptionInstance } from './Exceptions';
import { UnhandledExceptionsFilterService } from './UnhandledExceptionsFilterService';
/**
* Global exception handler to be used to report Exceptions to Application.Current.UnhandledException,
* the selection of which errors will be reported can be handled through filterService.
*
* Errors will be handled over to the ErrorHandler.handleError too
*
* @export
* @class UnhandledExceptionsHandler
* @extends {ErrorHandler}
*/
@Injectable()
export class UnhandledExceptionsHandler extends ErrorHandler {
/**
* Creates an instance of UnhandledExceptionsHandler.
* @param {UnhandledExceptionsFilterService} filterService service to be used to validate which
* exceptions must be reported
* @memberof UnhandledExceptionsHandler
*/
constructor(private filterService: UnhandledExceptionsFilterService) {
super();
}
/**
* Handles the error
*
* @param {*} er
* @memberof UnhandledExceptionsHandler
*/
handleError(er: any) {
super.handleError(er);
if (
Application?.Current?.UnhandledException?.fire &&
this.filterService.shouldBeReported(er)
) {
Application.Current.UnhandledException.fire([
Application.Current,
{
ExceptionObject: smGetExceptionInstance(er),
Handled: false,
},
]);
}
}
}