From 5f4595338a69cb5533a79133d1822c2e0f37b9cc Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Wed, 12 Jun 2024 14:15:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20frontend:=20Do=20not=20create=20?= =?UTF-8?q?template=20file=20if=20it=20failed=20to=20download?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/features/drive/hooks/use-drive-upload.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx b/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx index d71bf4e6..2b9e841b 100644 --- a/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx +++ b/tdrive/frontend/src/app/features/drive/hooks/use-drive-upload.tsx @@ -103,6 +103,8 @@ export const useDriveUpload = () => { request.responseType = 'blob'; request.onload = function () { 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); FileUploadService.upload([file], { context: { @@ -136,7 +138,8 @@ export const useDriveUpload = () => { }, }); } 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();