Merge branch 'main' into update-filetype-error-handling

This commit is contained in:
Abhinav 2023-01-31 19:59:25 +05:30
commit f599f7d88b
3 changed files with 15 additions and 9 deletions

View file

@ -1,5 +1,6 @@
import { ElectronAPIs } from 'types/electron'; import { ElectronAPIs } from 'types/electron';
import { ElectronFile } from 'types/upload'; import { ElectronFile } from 'types/upload';
import { CustomError } from 'utils/error';
import { convertBytesToHumanReadable } from 'utils/file/size'; import { convertBytesToHumanReadable } from 'utils/file/size';
import { addLogLine } from 'utils/logging'; import { addLogLine } from 'utils/logging';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
@ -37,7 +38,12 @@ class ElectronImageProcessorService {
); );
return new Blob([convertedFileData]); return new Blob([convertedFileData]);
} catch (e) { } catch (e) {
logError(e, 'failed to convert heic natively'); if (
e.message !==
CustomError.WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED
) {
logError(e, 'failed to convert heic natively');
}
throw e; throw e;
} }
} }
@ -68,7 +74,12 @@ class ElectronImageProcessorService {
); );
return thumb; return thumb;
} catch (e) { } catch (e) {
logError(e, 'failed to generate image thumbnail natively'); if (
e.message !==
CustomError.WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED
) {
logError(e, 'failed to generate image thumbnail natively');
}
throw e; throw e;
} }
} }

View file

@ -88,13 +88,6 @@ async function generateImageThumbnail(
MAX_THUMBNAIL_SIZE MAX_THUMBNAIL_SIZE
); );
} catch (e) { } catch (e) {
logError(
e,
'Error generating thumbnail using electron image processor',
{
fileFormat: fileTypeInfo.exactType,
}
);
return await generateImageThumbnailUsingCanvas(file, fileTypeInfo); return await generateImageThumbnailUsingCanvas(file, fileTypeInfo);
} }
} else { } else {

View file

@ -51,6 +51,8 @@ export const CustomError = {
UNKNOWN_ERROR: 'Something went wrong, please try again', UNKNOWN_ERROR: 'Something went wrong, please try again',
TYPE_DETECTION_FAILED: (fileFormat: string) => TYPE_DETECTION_FAILED: (fileFormat: string) =>
`type detection failed ${fileFormat}`, `type detection failed ${fileFormat}`,
WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED:
'Windows native image processing is not supported',
}; };
function parseUploadErrorCodes(error) { function parseUploadErrorCodes(error) {