matcher
matcher copied to clipboard
Add matchers for testing the stacktrace when an object is thrown
Hello!
When dealing with error handling, it's quite important to make sure that the proper stacktrace is passed around. But at the moment, we don't really have a matcher to test the stacktrace when an error is thrown.
I think it would be helpful if we had a way to simultaneously both check the error thrown and the stacktrace. For this, I think an optional parameter on throwsA would be helpful.
We would be able to write:
Matcher throwA(Object errorMatcher, [Object? stackTraceMatcher]);
await expectLater(
Future<int>.error(StateError(''), StackTrace.empty),
throwsA(isStateError, equals(StackTrace.empty)),
);