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
This commit is contained in:
Ferenc Sárai
2026-03-09 14:02:49 +01:00
committed by Bálint Ujvári
parent 7e05a56073
commit b58f01cc2b
+9
View File
@@ -145,6 +145,12 @@ export function Share(): ReactElement {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hash])
function downloadFailedWithError(err: unknown) {
const msg = <span>Error: {err instanceof Error ? err.message : String(err)}</span>
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
}