when<R> method
Pattern-matches on the variant, calling success or error and
returning the produced value.
Implementation
@override
R when<R>({
required R Function(T data) success,
required R Function(Failure failure) error,
}) =>
error(failure);