added better error handing

This commit is contained in:
Abhinav-grd 2021-02-18 12:54:17 +05:30
parent 8cbff31c36
commit ae96735dd2

View file

@ -164,7 +164,12 @@ class UploadService {
this.filesCompleted++; this.filesCompleted++;
this.changeProgressBarProps(); this.changeProgressBarProps();
} catch (e) { } 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.uploadErrors.push(error);
this.setUploadErrors(this.uploadErrors); this.setUploadErrors(this.uploadErrors);
} }
@ -228,6 +233,7 @@ class UploadService {
}; };
} catch (e) { } catch (e) {
console.log('error reading files ' + e); console.log('error reading files ' + e);
throw e;
} }
} }
private async encryptFile( private async encryptFile(
@ -270,6 +276,7 @@ class UploadService {
return result; return result;
} catch (e) { } catch (e) {
console.log('Error encrypting files ' + e); console.log('Error encrypting files ' + e);
throw e;
} }
} }
@ -325,6 +332,7 @@ class UploadService {
return response.data; return response.data;
} catch (e) { } catch (e) {
console.log('upload Files Failed ' + e); console.log('upload Files Failed ' + e);
throw e;
} }
} }
@ -456,14 +464,18 @@ class UploadService {
quality quality
); );
}); });
if (!thumbnailBlob) {
thumbnailBlob = file;
}
} while ( } while (
thumbnailBlob.size > MIN_THUMBNAIL_SIZE && thumbnailBlob.size > MIN_THUMBNAIL_SIZE &&
attempts <= MAX_ATTEMPTS attempts <= MAX_ATTEMPTS
); );
const thumbnail = this.getUint8ArrayView(thumbnailBlob); const thumbnail = await this.getUint8ArrayView(thumbnailBlob);
return thumbnail; return thumbnail;
} catch (e) { } catch (e) {
console.log('Error generating thumbnail ' + e); console.log('Error generating thumbnail ' + e);
throw e;
} }
} }
@ -556,6 +568,7 @@ class UploadService {
}; };
} catch (e) { } catch (e) {
console.log('error reading exif data'); console.log('error reading exif data');
throw e;
} }
} }
private getUNIXTime(exifData: any) { private getUNIXTime(exifData: any) {