From 491a692cd68cc843060c5c4206afe7a14639f98b Mon Sep 17 00:00:00 2001 From: Omar Date: Tue, 12 May 2026 21:38:21 +0200 Subject: [PATCH] Ignore flutter errors with no stack [skip ci] --- lib/utils/exception_handler.dart | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index e3f101c1d..42d289dd3 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -117,7 +117,7 @@ class ExceptionHandler { if (await onLedgerError(errorDetails)) return; if (kDebugMode || kProfileMode) { - if(_ignoreError(errorDetails.exception.toString()) || + if (_ignoreError(errorDetails.exception.toString()) || _ignoreError(errorDetails.stack.toString())) { printV("(BELOW ERROR IS IGNORED AND WILL NOT TRIGGER POPUP IN PROD)"); } @@ -127,7 +127,8 @@ class ExceptionHandler { } if (_ignoreError(errorDetails.exception.toString()) || - _ignoreError(errorDetails.stack.toString())) { + _ignoreError(errorDetails.stack.toString()) || + _flutterErrorIgnore(errorDetails)) { return; } @@ -215,8 +216,7 @@ class ExceptionHandler { return S.current.ledger_error_tx_rejected_by_user; } else if (errorCode.contains("5515")) { return S.current.ledger_error_device_locked; - } else - if (["6e01", "6d02", "6511", "6e00"].any((e) => errorCode.contains(e))) { + } else if (["6e01", "6d02", "6511", "6e00"].any((e) => errorCode.contains(e))) { return S.current.ledger_error_wrong_app; } return null; @@ -229,9 +229,8 @@ class ExceptionHandler { context: navigatorKey.currentContext!, builder: (context) => AlertWithOneAction( alertTitle: "Ledger Error", - alertContent: - interpretErrorCode(errorDetails.exception.toString()) ?? - S.of(context).ledger_connection_error, + alertContent: interpretErrorCode(errorDetails.exception.toString()) ?? + S.of(context).ledger_connection_error, buttonText: S.of(context).close, buttonAction: () => Navigator.of(context).pop(), ), @@ -296,7 +295,7 @@ class ExceptionHandler { "Wallet is null", "Wrong Device Status: 0x5515 (UNKNOWN)", "Command handling failed. With error: hostUnreachable", - + "FocusScopeNode was used after being disposed", "_getDismissibleFlushbar", "_QueuedFuture.execute (package:universal_ble/src/queue.dart:65)", @@ -439,4 +438,10 @@ class ExceptionHandler { _hasError = false; } + + static bool _flutterErrorIgnore(FlutterErrorDetails errorDetails) { + // most probably a flutter context error so just ignore it if there is no stack we can debug with + return errorDetails.exception.toString().contains("Null check operator used on a null value") && + errorDetails.stack == null; + } }