resolve method
Converts any error result into a successful result using a recovery function.
If this result is successful, returns it as-is.
If this result is an error, applies the onError function to convert
the error into a success value.
This ensures the returned result is always a Success, making it useful when you want to provide fallback values for any errors.
Implementation
Success<S, E> resolve({required S Function(E error) onError}) {
return switch (this) {
Success<S, E> sucs => sucs,
Error<S, E> err => Success(onError(err.error)),
};
}