tryRun<T> static method

KResult<T?> tryRun<T>(
  1. T? operation(), {
  2. bool logError = true,
})

Implementation

static KResult<T?> tryRun<T>(T? Function() operation, {bool logError = true}) {
  try {
    return KResult.success(operation());
  } catch (e, st) {
    return KResult.error(e.toString(), st, logError);
  }
}