trying method

Future<Either<Failure, Unit>> trying(
  1. Future<void> execute()
)

Implementation

Future<Either<Failure, Unit>> trying(
  Future<void> Function() execute,
) async {
  try {
    await execute.call();
    return const Right(unit);
  } on ReaderFailure catch (e) {
    return Left(e);
  } on IOFailure catch (e) {
    return Left(e);
  } catch (e) {
    return Left(IOFailure(cause: e.toString()));
  }
}