import { ErrorCodes } from './enums/error-codes.enum'; export class ErrorModel { errorDescription: string; errorDetails?: string; readonly errorCode: ErrorCodes; readonly memberName?: string; readonly originalDescription: string; constructor( errorCode: ErrorCodes, errorDescription: string, memberName?: string ) { this.errorCode = errorCode; this.errorDescription = errorDescription; this.originalDescription = errorDescription; this.memberName = memberName; } } export class BackendResponseModel { errors: ErrorModel[] = []; isShowNotification = true; data: any; addError( errorCode: ErrorCodes, errorDescription: string, errorDetails?: string ): ErrorModel { let error = this.errors.find((t) => t.errorCode === errorCode); if (!error) { error = new ErrorModel(errorCode, errorDescription); error.errorDetails = errorDetails; this.errors.push(error); } return error; } }