From 6bfe97be5d69adeb13dafad2016d1c76a9d2e67c Mon Sep 17 00:00:00 2001 From: Vojtech Simetka Date: Mon, 25 Jul 2022 07:26:01 +0200 Subject: [PATCH] feat: log errorss to consolve when showing error notification (#489) --- src/components/CashoutModal.tsx | 1 + src/components/WithdrawDepositModal.tsx | 1 + src/pages/files/Download.tsx | 1 + src/pages/files/Upload.tsx | 1 + src/pages/gift-code/index.tsx | 1 + src/pages/stamps/PostageStampCreation.tsx | 1 + src/pages/top-up/GiftCardFund.tsx | 2 ++ src/pages/top-up/GiftCardTopUpIndex.tsx | 1 + src/pages/top-up/Swap.tsx | 2 ++ src/pages/top-up/index.tsx | 1 + 10 files changed, 12 insertions(+) diff --git a/src/components/CashoutModal.tsx b/src/components/CashoutModal.tsx index 4df8130..ff3586d 100644 --- a/src/components/CashoutModal.tsx +++ b/src/components/CashoutModal.tsx @@ -48,6 +48,7 @@ export default function CheckoutModal({ peerId, uncashedAmount }: Props): ReactE ) }) .catch((e: Error) => { + console.error(e) // eslint-disable-line enqueueSnackbar(Error: {e.message}, { variant: 'error' }) }) .finally(() => { diff --git a/src/components/WithdrawDepositModal.tsx b/src/components/WithdrawDepositModal.tsx index 6824460..2401a87 100644 --- a/src/components/WithdrawDepositModal.tsx +++ b/src/components/WithdrawDepositModal.tsx @@ -55,6 +55,7 @@ export default function WithdrawDepositModal({ setOpen(false) enqueueSnackbar(`${successMessage} Transaction ${transactionHash}`, { variant: 'success' }) } catch (e) { + console.error(e) // eslint-disable-line enqueueSnackbar(`${errorMessage} Error: ${(e as Error).message}`, { variant: 'error' }) } } diff --git a/src/pages/files/Download.tsx b/src/pages/files/Download.tsx index 0688e51..95f1ca7 100644 --- a/src/pages/files/Download.tsx +++ b/src/pages/files/Download.tsx @@ -75,6 +75,7 @@ export function Download(): ReactElement { if (message.includes('Not Found: Not Found')) { message = 'The specified hash was not found.' } + console.error(error) // eslint-disable-line enqueueSnackbar(Error: {message || 'Unknown'}, { variant: 'error' }) } finally { setLoading(false) diff --git a/src/pages/files/Upload.tsx b/src/pages/files/Upload.tsx index 28c6bdd..a2e9ef3 100644 --- a/src/pages/files/Upload.tsx +++ b/src/pages/files/Upload.tsx @@ -147,6 +147,7 @@ export function Upload(): ReactElement { } }) .catch(e => { + console.error(e) // eslint-disable-line enqueueSnackbar(`Error uploading: ${e.message}`, { variant: 'error' }) setUploading(false) }) diff --git a/src/pages/gift-code/index.tsx b/src/pages/gift-code/index.tsx index 9d860a1..99203fa 100644 --- a/src/pages/gift-code/index.tsx +++ b/src/pages/gift-code/index.tsx @@ -51,6 +51,7 @@ export default function Index(): ReactElement { await createGiftWallet(wallet.address) enqueueSnackbar('Succesfully funded gift wallet', { variant: 'success' }) } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to fund gift wallet: ${error}`, { variant: 'error' }) } finally { setLoading(false) diff --git a/src/pages/stamps/PostageStampCreation.tsx b/src/pages/stamps/PostageStampCreation.tsx index b29075e..177dfff 100644 --- a/src/pages/stamps/PostageStampCreation.tsx +++ b/src/pages/stamps/PostageStampCreation.tsx @@ -109,6 +109,7 @@ export function PostageStampCreation({ onFinished }: Props): ReactElement { await refresh() onFinished() } catch (e) { + console.error(e) // eslint-disable-line enqueueSnackbar(`Error: ${(e as Error).message}`, { variant: 'error' }) actions.setSubmitting(false) } diff --git a/src/pages/top-up/GiftCardFund.tsx b/src/pages/top-up/GiftCardFund.tsx index c4332fb..c14d7e4 100644 --- a/src/pages/top-up/GiftCardFund.tsx +++ b/src/pages/top-up/GiftCardFund.tsx @@ -55,6 +55,7 @@ export function GiftCardFund(): ReactElement { enqueueSnackbar('Upgraded to light node', { variant: 'success' }) navigate(ROUTES.RESTART_LIGHT) } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to upgrade: ${error}`, { variant: 'error' }) } } @@ -72,6 +73,7 @@ export function GiftCardFund(): ReactElement { if (canUpgradeToLightNode) await restart() } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to fund: ${error}`, { variant: 'error' }) } finally { setLoading(false) diff --git a/src/pages/top-up/GiftCardTopUpIndex.tsx b/src/pages/top-up/GiftCardTopUpIndex.tsx index 5c24e14..f46faff 100644 --- a/src/pages/top-up/GiftCardTopUpIndex.tsx +++ b/src/pages/top-up/GiftCardTopUpIndex.tsx @@ -38,6 +38,7 @@ export function GiftCardTopUpIndex(): ReactElement { enqueueSnackbar('Successfully verified gift wallet', { variant: 'success' }) navigate(ROUTES.TOP_UP_GIFT_CODE_FUND.replace(':privateKeyString', giftCode)) } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Gift wallet could not be verified: ${error}`, { variant: 'error' }) } finally { setLoading(false) diff --git a/src/pages/top-up/Swap.tsx b/src/pages/top-up/Swap.tsx index ca0575a..62a9d92 100644 --- a/src/pages/top-up/Swap.tsx +++ b/src/pages/top-up/Swap.tsx @@ -85,6 +85,7 @@ export function Swap({ header }: Props): ReactElement { enqueueSnackbar('Upgraded to light node', { variant: 'success' }) navigate(ROUTES.RESTART_LIGHT) } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to upgrade: ${error}`, { variant: 'error' }) } } @@ -101,6 +102,7 @@ export function Swap({ header }: Props): ReactElement { if (canUpgradeToLightNode) await restart() } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to swap: ${error}`, { variant: 'error' }) } finally { balance?.refresh() diff --git a/src/pages/top-up/index.tsx b/src/pages/top-up/index.tsx index 19288aa..a90bcdf 100644 --- a/src/pages/top-up/index.tsx +++ b/src/pages/top-up/index.tsx @@ -58,6 +58,7 @@ export default function TopUp(): ReactElement { enqueueSnackbar('Upgraded to light node', { variant: 'success' }) navigate(ROUTES.RESTART_LIGHT) } catch (error) { + console.error(error) // eslint-disable-line enqueueSnackbar(`Failed to upgrade: ${error}`, { variant: 'error' }) } setLoading(false)