toFailure<R> static method

Future<Fos<Failure, R>> toFailure<R>(
  1. Object exception
)

use this method to convert exception to failure example: try { final user = await findUsers("$params"); return Fos.success(user); } catch (e) { return Fos.toFailure(e); }

Implementation

static Future<Fos<Failure, R>> toFailure<R>(Object exception) async {
  final failure = errors.entries.firstWhere((element) => element.key == exception).value;
  return Fos.failure(failure);
}