fix: refine Ledger error code interpretation and enhance error handling [skip-ci]

This commit is contained in:
Konstantin Ullrich 2025-06-18 22:01:20 +02:00
parent 6260c4cf3a
commit b53cd162c8
No known key found for this signature in database
GPG key ID: 6B3199AD9B3D23B8
4 changed files with 12 additions and 14 deletions

View file

@ -30,6 +30,7 @@ dependencies:
git: git:
url: https://github.com/cake-tech/ledger-flutter-plus-plugins url: https://github.com/cake-tech/ledger-flutter-plus-plugins
path: packages/ledger-ethereum path: packages/ledger-ethereum
ref: f4761cd5171d4c1e2e42fd3298261650539fb2db
dependency_overrides: dependency_overrides:
web3dart: web3dart:

View file

@ -212,6 +212,8 @@ class ExceptionHandler {
return null; return null;
} }
printV(errorDetails.exception);
if (navigatorKey.currentContext != null) { if (navigatorKey.currentContext != null) {
await showPopUp<void>( await showPopUp<void>(
context: navigatorKey.currentContext!, context: navigatorKey.currentContext!,

View file

@ -177,17 +177,14 @@ abstract class LedgerViewModelBase with Store {
} }
String? interpretErrorCode(String errorCode) { String? interpretErrorCode(String errorCode) {
switch (errorCode) { if (errorCode.contains("6985")) {
case "6985":
return S.current.ledger_error_tx_rejected_by_user; return S.current.ledger_error_tx_rejected_by_user;
case "5515": } else if (errorCode.contains("5515")) {
return S.current.ledger_error_device_locked; return S.current.ledger_error_device_locked;
case "6d02": // UNKNOWN_APDU } else
case "6511": if (["6e01", "6a87", "6d02", "6511", "6e00"].any((e) => errorCode.contains(e))) {
case "6e00":
return S.current.ledger_error_wrong_app; return S.current.ledger_error_wrong_app;
default: }
return null; return null;
} }
}
} }

View file

@ -80,11 +80,9 @@ abstract class WalletHardwareRestoreViewModelBase extends WalletCreationVM with
availableAccounts.addAll(accounts); availableAccounts.addAll(accounts);
_nextIndex += limit; _nextIndex += limit;
// } on LedgerException catch (e) {
// error = ledgerViewModel.interpretErrorCode(e.errorCode.toRadixString(16));
} catch (e) { } catch (e) {
printV(e); printV(e);
error = S.current.ledger_connection_error; error = ledgerViewModel.interpretErrorCode(e.toString()) ?? S.current.ledger_connection_error;
} }
isLoadingMoreAccounts = false; isLoadingMoreAccounts = false;