renamed parseError and handleError to upload specfic names

This commit is contained in:
Abhinav-grd 2021-08-29 11:47:37 +05:30
parent c57989d14f
commit ce8bc629a1
3 changed files with 8 additions and 10 deletions

View file

@ -17,7 +17,7 @@ import { encryptFiledata } from './encryptionService';
import { ENCRYPTION_CHUNK_SIZE } from 'types';
import { uploadStreamUsingMultipart } from './multiPartUploadService';
import UIService from './uiService';
import { parseError } from 'utils/common/errorUtil';
import { handleUploadError } from 'utils/common/errorUtil';
import { MetadataMap } from './uploadManager';
import { fileIsHEIC } from 'utils/file';
@ -258,10 +258,7 @@ class UploadService {
await this.fetchUploadURLs();
// checking for any subscription related errors
} catch (e) {
const { parsedError, parsed } = parseError(e);
if (parsed) {
throw parsedError;
}
handleUploadError(e);
}
}

View file

@ -1,6 +1,6 @@
import { File, FILE_TYPE } from 'services/fileService';
import { sleep } from 'utils/common';
import { handleError, CustomError } from 'utils/common/errorUtil';
import { handleUploadError, CustomError } from 'utils/common/errorUtil';
import { decryptFile } from 'utils/file';
import { logError } from 'utils/sentry';
import { fileAlreadyInCollection } from 'utils/upload';
@ -98,7 +98,7 @@ export default async function uploader(
const fileFormat =
fileTypeInfo.exactType ?? rawFile.name.split('.')[-1];
logError(e, 'file upload failed', { fileFormat });
handleError(e);
handleUploadError(e);
switch (e.message) {
case CustomError.ETAG_MISSING:
UIService.setFileProgress(

View file

@ -1,3 +1,4 @@
import { AxiosResponse } from 'axios';
import constants from 'utils/strings/constants';
export const ServerErrorCodes = {
@ -19,7 +20,7 @@ export const CustomError = {
UNSUPPORTED_FILE_FORMAT: 'unsupported file formats',
};
export function parseError(error) {
function parseUploadError(error: AxiosResponse) {
let parsedMessage = null;
if (error?.status) {
const errorCode = error.status.toString();
@ -48,8 +49,8 @@ export function parseError(error) {
}
}
export function handleError(error) {
const { parsedError, parsed } = parseError(error);
export function handleUploadError(error: AxiosResponse) {
const { parsedError, parsed } = parseUploadError(error);
if (parsed) {
throw parsedError;
} else {