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 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 296fe17fcb3f..82704f2a1f96 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" @@ -6973,4 +6974,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..89184b7362c5 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 && ( + + )}