Skip to content

Commit

Permalink
add error handling to swap & deposit ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridel1e committed Aug 23, 2023
1 parent 5cac7c5 commit 2bf42ac
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/common/services/ErrorLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ export const addErrorLog =

export const downloadErrorLog = () => {
saveAs(
new Blob([JSON.stringify(errorLogs, null, 2)], {
type: 'text/plain;charset=utf-8',
}),
new Blob(
[
JSON.stringify(
errorLogs,
(key, value) =>
typeof value === 'bigint' ? value.toString() : value,
2,
),
],
{
type: 'text/plain;charset=utf-8',
},
),
'logs.txt',
);
};
9 changes: 9 additions & 0 deletions src/components/common/Layout/Header/BurgerMenu/BurgerMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Button,
DownloadOutlined,
Dropdown,
FileTextOutlined,
GithubOutlined,
Expand All @@ -23,6 +24,7 @@ import {
LOCALE_LABEL,
SUPPORTED_LOCALES,
} from '../../../../../common/constants/locales';
import { downloadErrorLog } from '../../../../../common/services/ErrorLogs';
import { useApplicationSettings } from '../../../../../context';
import { useQuery } from '../../../../../hooks/useQuery';
import { ThemeSwitch } from '../../../../ThemeSwitch/ThemeSwitch';
Expand Down Expand Up @@ -100,6 +102,13 @@ const BurgerMenu = (): JSX.Element => {
setIsMainMenu(false);
},
},
{
title: t`Download Error Log`,
icon: <DownloadOutlined />,
onClick: () => {
downloadErrorLog();
},
},
];

const changeLanguage = (locale: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/network/cardano/api/operations/deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const useDepositValidators =
Sentry.captureMessage(error?.message || (error as any), {
level: Severity.Critical,
});
addErrorLog({ op: 'depositValidation', ctx: data[2] })(error);
}

return data[0]
Expand Down
2 changes: 2 additions & 0 deletions src/network/cardano/api/operations/swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ export const useSwapValidators = (): OperationValidator<SwapFormModel>[] => {
map(
(data: [Transaction | null, TxCandidate, SwapTxInfo, Error | null]) => {
const error = data[3];

if (error && !data[0]) {
Sentry.captureMessage(error?.message || (error as any), {
level: Severity.Critical,
});
addErrorLog({ op: 'swapValidation', ctx: data[2] })(error);
}
return data[0]
? undefined
Expand Down

0 comments on commit 2bf42ac

Please sign in to comment.