expectErr<T> function
Assert result is Err and return its problem; throws otherwise.
Implementation
Problem expectErr<T>(Result<T> result, {String? because}) => switch (result) {
Ok<T>(:final value) => throw AssertionError(
'expected Err but got Ok($value)${because == null ? '' : ' — $because'}',
),
Err<T>(:final problem) => problem,
};