From ae96735dd2c2d27af47ea61e8c944dceed0b8709 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Thu, 18 Feb 2021 12:54:17 +0530 Subject: [PATCH] added better error handing --- src/services/uploadService.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/services/uploadService.ts b/src/services/uploadService.ts index ae2f56b76..469ec24d4 100644 --- a/src/services/uploadService.ts +++ b/src/services/uploadService.ts @@ -164,7 +164,12 @@ class UploadService { this.filesCompleted++; this.changeProgressBarProps(); } catch (e) { - const error = new Error(`Error Uploading File ${rawFile.name}`); + if (e.response?.status == 402 || e.response?.status == 426) { + throw e; + } + const error = new Error( + `Uploading Failed for File - ${rawFile.name}` + ); this.uploadErrors.push(error); this.setUploadErrors(this.uploadErrors); } @@ -228,6 +233,7 @@ class UploadService { }; } catch (e) { console.log('error reading files ' + e); + throw e; } } private async encryptFile( @@ -270,6 +276,7 @@ class UploadService { return result; } catch (e) { console.log('Error encrypting files ' + e); + throw e; } } @@ -325,6 +332,7 @@ class UploadService { return response.data; } catch (e) { console.log('upload Files Failed ' + e); + throw e; } } @@ -456,14 +464,18 @@ class UploadService { quality ); }); + if (!thumbnailBlob) { + thumbnailBlob = file; + } } while ( thumbnailBlob.size > MIN_THUMBNAIL_SIZE && attempts <= MAX_ATTEMPTS ); - const thumbnail = this.getUint8ArrayView(thumbnailBlob); + const thumbnail = await this.getUint8ArrayView(thumbnailBlob); return thumbnail; } catch (e) { console.log('Error generating thumbnail ' + e); + throw e; } } @@ -556,6 +568,7 @@ class UploadService { }; } catch (e) { console.log('error reading exif data'); + throw e; } } private getUNIXTime(exifData: any) {