Ignore flutter errors with no stack [skip ci]
Omar committed
May 12, 2026 at 21:38 UTC
491a692cd68cc843060c5c4206afe7a14639f98b
1 file changed
+13
-8
lib/utils/exception_handler.dart
+13
-8
@@ -117,7 +117,7 @@ class ExceptionHandler {
117
if (await onLedgerError(errorDetails)) return;
118
119
if (kDebugMode || kProfileMode) {
120
- if(_ignoreError(errorDetails.exception.toString()) ||
120
+ if (_ignoreError(errorDetails.exception.toString()) ||
121
_ignoreError(errorDetails.stack.toString())) {
122
printV("(BELOW ERROR IS IGNORED AND WILL NOT TRIGGER POPUP IN PROD)");
123
}
@@ -127,7 +127,8 @@ class ExceptionHandler {
127
}
128
129
if (_ignoreError(errorDetails.exception.toString()) ||
130
- _ignoreError(errorDetails.stack.toString())) {
130
+ _ignoreError(errorDetails.stack.toString()) ||
131
+ _flutterErrorIgnore(errorDetails)) {
132
return;
133
}
134
@@ -215,8 +216,7 @@ class ExceptionHandler {
216
return S.current.ledger_error_tx_rejected_by_user;
217
} else if (errorCode.contains("5515")) {
218
return S.current.ledger_error_device_locked;
218
- } else
219
- if (["6e01", "6d02", "6511", "6e00"].any((e) => errorCode.contains(e))) {
219
+ } else if (["6e01", "6d02", "6511", "6e00"].any((e) => errorCode.contains(e))) {
220
return S.current.ledger_error_wrong_app;
221
}
222
return null;
@@ -229,9 +229,8 @@ class ExceptionHandler {
229
context: navigatorKey.currentContext!,
230
builder: (context) => AlertWithOneAction(
231
alertTitle: "Ledger Error",
232
- alertContent:
233
- interpretErrorCode(errorDetails.exception.toString()) ??
234
- S.of(context).ledger_connection_error,
232
+ alertContent: interpretErrorCode(errorDetails.exception.toString()) ??
233
+ S.of(context).ledger_connection_error,
234
buttonText: S.of(context).close,
235
buttonAction: () => Navigator.of(context).pop(),
236
),
@@ -296,7 +295,7 @@ class ExceptionHandler {
295
"Wallet is null",
296
"Wrong Device Status: 0x5515 (UNKNOWN)",
297
"Command handling failed. With error: hostUnreachable",
299
-
298
+
299
"FocusScopeNode was used after being disposed",
300
"_getDismissibleFlushbar",
301
"_QueuedFuture.execute (package:universal_ble/src/queue.dart:65)",
@@ -439,4 +438,10 @@ class ExceptionHandler {
438
439
_hasError = false;
440
}
441
+
442
+ static bool _flutterErrorIgnore(FlutterErrorDetails errorDetails) {
443
+ // most probably a flutter context error so just ignore it if there is no stack we can debug with
444
+ return errorDetails.exception.toString().contains("Null check operator used on a null value") &&
445
+ errorDetails.stack == null;
446
+ }
447
}