Skip to content

Commit

Permalink
feat: error handling llm
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduma-ledger committed Sep 17, 2024
1 parent a2f08e9 commit 9713e05
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { ScreenName } from "~/const";

export type CustomErrorNavigatorParamList = {
[ScreenName.CustomErrorScreen]: {
error?: SwapLiveError;
error?: SwapLiveError | Error;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
},
});
Expand Down
5 changes: 3 additions & 2 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -6955,4 +6956,4 @@
}
}
}
}
}
17 changes: 13 additions & 4 deletions apps/ledger-live-mobile/src/screens/CustomError/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ export default function CustomError({ route }: CustomErrorPropsProps) {
<Text variant="body" textAlign={"center"}>
{t("errors.CustomError.description")}

<Trans
i18nKey="errors.CustomError.errorCode"
values={{ errorCode: error?.cause.swapCode }}
/>
{error && "cause" in error && error.cause?.swapCode && (
<Trans
i18nKey="errors.CustomError.errorCode"
values={{ errorCode: error?.cause.swapCode }}
/>
)}

{error && "message" in error && error?.message && (
<Trans
i18nKey="errors.CustomError.errorMessage"
values={{ errorMessage: error?.message }}
/>
)}
</Text>
</Flex>
</SafeAreaView>
Expand Down

0 comments on commit 9713e05

Please sign in to comment.