From 9713e05738c1268d0489113b710ff7301c34a36d Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Tue, 17 Sep 2024 13:50:03 +0300 Subject: [PATCH 1/3] feat: error handling llm --- .../RootNavigator/types/CustomErrorNavigator.ts | 2 +- .../components/WebPTXPlayer/CustomHandlers.ts | 9 ++++++++- .../src/locales/en/common.json | 5 +++-- .../src/screens/CustomError/index.tsx | 17 +++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/types/CustomErrorNavigator.ts b/apps/ledger-live-mobile/src/components/RootNavigator/types/CustomErrorNavigator.ts index bce10cee7646..8f2c41a65628 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/types/CustomErrorNavigator.ts +++ b/apps/ledger-live-mobile/src/components/RootNavigator/types/CustomErrorNavigator.ts @@ -3,6 +3,6 @@ import { ScreenName } from "~/const"; export type CustomErrorNavigatorParamList = { [ScreenName.CustomErrorScreen]: { - error?: SwapLiveError; + error?: SwapLiveError | Error; }; }; diff --git a/apps/ledger-live-mobile/src/components/WebPTXPlayer/CustomHandlers.ts b/apps/ledger-live-mobile/src/components/WebPTXPlayer/CustomHandlers.ts index 84b25243c26b..d0e00f93d1de 100644 --- a/apps/ledger-live-mobile/src/components/WebPTXPlayer/CustomHandlers.ts +++ b/apps/ledger-live-mobile/src/components/WebPTXPlayer/CustomHandlers.ts @@ -88,12 +88,19 @@ export function usePTXCustomHandlers(manifest: WebviewProps["manifest"]) { onResult: result => { if (result.error) { onCancel(result.error); + navigation.pop(); + navigation.navigate(NavigatorName.CustomError, { + screen: ScreenName.CustomErrorScreen, + params: { + error: result.error, + }, + }); } if (result.operation) { onSuccess(result.operation.id); } setDevice(undefined); - navigation.pop(); + !result.error && navigation.pop(); }, }, }); diff --git a/apps/ledger-live-mobile/src/locales/en/common.json b/apps/ledger-live-mobile/src/locales/en/common.json index 78196b972dd8..b5c73cc46a44 100644 --- a/apps/ledger-live-mobile/src/locales/en/common.json +++ b/apps/ledger-live-mobile/src/locales/en/common.json @@ -947,7 +947,8 @@ "CustomError": { "title": "Sorry, try again.", "description": "The server could not handle your request. Please try again later or contact Ledger Support.", - "errorCode": "Code: {{errorCode}}" + "errorCode": "Code: {{errorCode}}", + "errorMessage": "{{errorMessage}}" }, "TrustchainEjected": { "title": "Not Synced anymore" @@ -6955,4 +6956,4 @@ } } } -} +} \ No newline at end of file diff --git a/apps/ledger-live-mobile/src/screens/CustomError/index.tsx b/apps/ledger-live-mobile/src/screens/CustomError/index.tsx index 32df647f758a..6622ab7843de 100644 --- a/apps/ledger-live-mobile/src/screens/CustomError/index.tsx +++ b/apps/ledger-live-mobile/src/screens/CustomError/index.tsx @@ -28,10 +28,19 @@ export default function CustomError({ route }: CustomErrorPropsProps) { {t("errors.CustomError.description")} - + {error && "cause" in error && error.cause?.swapCode && ( + + )} + + {error && "message" in error && error?.message && ( + + )} From e3b503046f91e176494c90083685af9fad279526 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Tue, 17 Sep 2024 13:51:08 +0300 Subject: [PATCH 2/3] chore: changeset --- .changeset/giant-pants-deliver.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-pants-deliver.md diff --git a/.changeset/giant-pants-deliver.md b/.changeset/giant-pants-deliver.md new file mode 100644 index 000000000000..37ac5e8762ab --- /dev/null +++ b/.changeset/giant-pants-deliver.md @@ -0,0 +1,5 @@ +--- +"live-mobile": minor +--- + +Adds error handling for LLM From 72c6c4c4f1c5f62608c0f0f7814b3b6875a03701 Mon Sep 17 00:00:00 2001 From: chrisduma-ledger Date: Tue, 17 Sep 2024 13:53:55 +0300 Subject: [PATCH 3/3] chore: remove guard --- apps/ledger-live-mobile/src/screens/CustomError/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/ledger-live-mobile/src/screens/CustomError/index.tsx b/apps/ledger-live-mobile/src/screens/CustomError/index.tsx index 6622ab7843de..89184b7362c5 100644 --- a/apps/ledger-live-mobile/src/screens/CustomError/index.tsx +++ b/apps/ledger-live-mobile/src/screens/CustomError/index.tsx @@ -31,14 +31,14 @@ export default function CustomError({ route }: CustomErrorPropsProps) { {error && "cause" in error && error.cause?.swapCode && ( )} - {error && "message" in error && error?.message && ( + {error && "message" in error && error.message && ( )}