tryCatchAsync<T> function

Future<T?> tryCatchAsync<T>(
  1. FutureOr<T> worker(), [
  2. Future<T?> onError(
    1. dynamic e
    )?
])

Implementation

Future<T?> tryCatchAsync<T>(FutureOr<T> Function() worker,
    [Future<T?> Function(dynamic e)? onError]) async {
  try {
    return await worker();
  } catch (e) {
    return onError?.call(e);
  }
}