runErrorFuture<T> method

  1. @override
Future<T?> runErrorFuture<T>(
  1. Future<T?> future, {
  2. Object? key,
  3. bool throwException = false,
})
override

Implementation

@override
Future<T?> runErrorFuture<T>(
  Future<T?> future, {
  Object? key,
  bool throwException = false,
}) async {
  final _key = key ?? typeName;
  try {
    final result = await future;
    if (result is GetResult && result.error != null) {
      setErrorFor(_key, result.error);
      onError(_key, result.error);
      if (throwException) throw result.error!;
    }
    return result;
  } catch (e) {
    setErrorFor(_key, e);
    onError(e, _key);
    if (throwException) rethrow;
    return Future.value();
  }
}