Files
swiftcontrol/test/error_context_test.dart
Jonas Bark bca8fee0be Bump prop submodule: drop unhostable Cycling Power on Windows BLE; relabel handled errors
- prop 9ec8e83: BluetoothTransporter no longer registers/advertises the Cycling
  Power service (0x1818) on Windows when FTMS is present, fixing the handled
  'Service not found for advertising' PlatformException seen in support logs.
- main.dart: _persistCrash now labels caught errors 'Handled error <type>:' and
  reserves 'App crashed <type>:' for genuinely-uncaught contexts
  (isFatalErrorContext: Zone/PlatformDispatcher/Isolate), so handled errors stop
  reading as crashes in the diagnostics log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 21:55:06 +02:00

24 lines
997 B
Dart

import 'package:bike_control/main.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('isFatalErrorContext', () {
// The persisted error log labels entries "App crashed" only for genuinely
// uncaught errors caught by the app's top-level guards. Handled errors
// funneled through record() from a try/catch (e.g. 'Retrofit Switch') must
// NOT read as crashes — that mislabel made a handled BLE-advertise failure
// look like an app crash in a support log.
test('top-level uncaught guards are fatal', () {
expect(isFatalErrorContext('Zone'), isTrue);
expect(isFatalErrorContext('PlatformDispatcher'), isTrue);
expect(isFatalErrorContext('Isolate'), isTrue);
});
test('handled try/catch contexts are not fatal', () {
expect(isFatalErrorContext('Retrofit Switch'), isFalse);
expect(isFatalErrorContext('Emulator start'), isFalse);
expect(isFatalErrorContext('SettingsInit'), isFalse);
});
});
}