From b58f01cc2b5535ba0ad347d03ae4102e18f637f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20S=C3=A1rai?= Date: Mon, 9 Mar 2026 14:02:49 +0100 Subject: [PATCH] fix: add error handling and ui notifications for download failures (#217) * fix: add error handling and ui notifications for download failures * fix: refactor error handling for download failures --- src/pages/files/Share.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/files/Share.tsx b/src/pages/files/Share.tsx index 09d878c..9d0f9a4 100644 --- a/src/pages/files/Share.tsx +++ b/src/pages/files/Share.tsx @@ -145,6 +145,12 @@ export function Share(): ReactElement { // eslint-disable-next-line react-hooks/exhaustive-deps }, [hash]) + function downloadFailedWithError(err: unknown) { + const msg = Error: {err instanceof Error ? err.message : String(err)} + enqueueSnackbar(msg, { variant: 'error' }) + setDownloading(false) + } + async function onDownload() { if (!beeApi || !hash) { // eslint-disable-next-line no-console @@ -166,6 +172,7 @@ export function Share(): ReactElement { } catch (err) { // eslint-disable-next-line no-console console.error('Failed to download file: ', err) + downloadFailedWithError(err) return } @@ -184,6 +191,7 @@ export function Share(): ReactElement { } catch (err) { // eslint-disable-next-line no-console console.error('Failed to download files: ', err) + downloadFailedWithError(err) return } @@ -195,6 +203,7 @@ export function Share(): ReactElement { } catch (err) { // eslint-disable-next-line no-console console.error('Failed to compress file: ', err) + downloadFailedWithError(err) return }