import { isArray } from 'lodash-es'; import { BaseErrorHandler } from './base-error.handler'; import { BackendResponseModel, ErrorModel } from '../../models'; export class BusinessLogicExceptionHandler extends BaseErrorHandler { handle(): BackendResponseModel { const data: { errors: { errorCode: number; message: string; memberName: string }[]; } = this.httpResponseError?.errors[0].message; const result = new BackendResponseModel(); result.isShowNotification = true; result.errors = data.errors.map( (t) => new ErrorModel(t.errorCode, t.message, t.memberName) ); return result; } canHandle(): boolean { try { return isArray( this.httpResponseError?.errors && this.httpResponseError.errors[0] && this.httpResponseError.errors[0].message.errors ); } catch {} return false; } }