getError method

Returns the error value if the result is an error, otherwise throws an exception.

Implementation

@visibleForTesting
Failure getError() =>
    fold((e) => e, (r) => throw Failure(message: 'No error'));