import combineErrors from "combine-errors" ; import { ErrorHandler , Injectable , Injector } from "@angular/core" ; import { Store } from "@ngrx/store" ; import { pick } from "remeda" ; import { serializeError } from "serialize-error" ; import { NOTIFICATION_ACTIONS } from "./store/actions" ; import { getWebLogger } from "src/web/browser-window/util" ; const logger = getWebLogger ( __filename ) ; @ Injectable ( ) export class AppErrorHandler implements ErrorHandler { constructor ( private readonly injector ) { } handleError ( error ) { ( ( ) => { const { errors } = error ; logger . error ( serializeError ( pick ( Array . isArray ( errors ) && errors . length ? combineErrors ( [ error , ... errors ] ) : error , [ "name" , "message" , "stack" ] ) ) ) ; } ) ( ) ; this . injector . get ( Store ) . dispatch ( NOTIFICATION_ACTIONS . ErrorSkipLogging ( error ) ) ; } }