diff --git a/src/services/machineLearning/machineLearningService.ts b/src/services/machineLearning/machineLearningService.ts index 1334b1184..9cde6259a 100644 --- a/src/services/machineLearning/machineLearningService.ts +++ b/src/services/machineLearning/machineLearningService.ts @@ -24,7 +24,7 @@ import { getAllFacesFromMap } from 'utils/machineLearning'; import { MLFactory } from './machineLearningFactory'; import mlIDbStorage from 'utils/storage/mlIDbStorage'; import { getMLSyncConfig } from 'utils/machineLearning/config'; -import { CustomError, parseServerError } from 'utils/error'; +import { CustomError, parseUploadErrorCodes } from 'utils/error'; import { MAX_ML_SYNC_ERROR_COUNT } from 'constants/machineLearning/config'; import FaceService from './faceService'; import PeopleService from './peopleService'; @@ -379,8 +379,8 @@ class MachineLearningService { error ); if ('status' in error) { - const parsedMessage = parseServerError(error); - error = parsedMessage ? new Error(parsedMessage) : error; + const parsedMessage = parseUploadErrorCodes(error); + error = parsedMessage; } // TODO: throw errors not related to specific file // sync job run should stop after these errors diff --git a/src/utils/error/index.ts b/src/utils/error/index.ts index 4298438fb..c77d6aae8 100644 --- a/src/utils/error/index.ts +++ b/src/utils/error/index.ts @@ -51,7 +51,7 @@ export enum CustomError { UNKNOWN_ERROR = 'Something went wrong, please try again', } -function parseUploadErrorCodes(error) { +export function parseUploadErrorCodes(error) { let parsedMessage = null; if (error?.status) { const errorCode = error.status.toString();