🐛 frontend: Do not create template file if it failed to download

This commit is contained in:
Eric Doughty-Papassideris
2024-06-12 14:15:08 +02:00
committed by ericlinagora
parent acb8c1e757
commit 5f4595338a
@@ -103,6 +103,8 @@ export const useDriveUpload = () => {
request.responseType = 'blob'; request.responseType = 'blob';
request.onload = function () { request.onload = function () {
try { try {
if (request.status != 200)
throw new Error(`Unexpected response status code: ${request.status} from ${JSON.stringify(url)}`);
const file = new File([request.response], name); const file = new File([request.response], name);
FileUploadService.upload([file], { FileUploadService.upload([file], {
context: { context: {
@@ -136,7 +138,8 @@ export const useDriveUpload = () => {
}, },
}); });
} catch (e) { } catch (e) {
ToasterService.error('Error while creating an empty file.'); logger.error(`Error creating file`, e);
ToasterService.error('Error while creating a new file from template.');
} }
}; };
request.send(); request.send();