useCase<T> function

Future<UseCase<T>> useCase<T>(
  1. Future<T> request()
)

Executes the given async request and returns a UseCase with the result.

Implementation

Future<UseCase<T>> useCase<T>(Future<T> Function() request) async {
  try {
    return UseCaseSuccess(await request());
  } on UseCaseException catch (ex) {
    return UseCaseFailure(ex);
  } catch (ex, st) {
    return UseCaseFailure(UnexpectedUseCaseException(ex.toString(), st));
  }
}