rehlma / flutter-preserve-error-contextr1
Preserve the error and its stack trace
PublicCatch with error and stackTrace, and forward both through the logger’s named arguments.
tests, run by the registry5 passed · slowest 2.1 ms
✓fires2.1 ms
reports newly written problematic code
write lib/example.dart · in fixtures/flutterfired: line 1
} catch (e) {✓quiet1.5 ms
allows the intended form
write lib/example.dart · in fixtures/flutterstayed quiet
} catch (error, stackTrace) {✓quiet1.8 ms
does not apply to a pure Dart package
write lib/example.dart · in fixtures/dartstayed quiet
} catch (e) {✓skips0.0 ms
does not judge reads
read lib/example.dart · in fixtures/flutterno handler of the detector wants this event
} catch (e) {✓quiet1.5 ms
does not report an untouched legacy line
write lib/example.dart · in fixtures/flutter · wrote line 2stayed quiet
} catch (e) {
final added = 1;detector.test.tseach detect() call runs the real detector
import { expect, test } from 'vitest';
import { detect, write, edit, read, command, output, prompt } from '@wellactually/sdk/v3/test';
const flutter = { project: 'fixtures/flutter' };
const dart = { project: 'fixtures/dart' };
test('reports newly written problematic code', () => {
expect(detect(write("lib/example.dart", "} catch (e) {"), flutter)).toEqual([{ line: 1 }]);
});
test('allows the intended form', () => {
expect(detect(write("lib/example.dart", "} catch (error, stackTrace) {"), flutter)).toEqual([]);
});
test('does not apply to a pure Dart package', () => {
expect(detect(write("lib/example.dart", "} catch (e) {"), dart)).toEqual([]);
});
test('does not judge reads', () => {
expect(detect(read("lib/example.dart", "} catch (e) {"), flutter)).toEqual([]);
});
test('does not report an untouched legacy line', () => {
expect(detect(edit("lib/example.dart", "} catch (e) {\nfinal added = 1;", { written: 'final added = 1;' }), flutter)).toEqual([]);
});