fails<T> static method
result is Err with code; answers the error.
Implementation
static DbError fails<T>(
Result<T, DbError> result,
DbErrorCode code,
String what,
) => result.when(
ok: (value) => throw ConformanceFailure(
'$what: expected ${code.name}, got Ok($value)',
),
err: (error) => error.code == code
? error
: throw ConformanceFailure(
'$what: expected ${code.name}, got ${error.code.name} ($error)',
),
);