tryRunAsync<T> static method
Runs operation and wraps the result in a KResult.success or KResult.error if it throws.
Implementation
static Future<KResult<T?>> tryRunAsync<T>(Future<T?> Function() operation, {bool logError = true}) async {
try {
return KResult.success(await operation());
} catch (e, st) {
if (logError) {
log("Result tryRunAsync error: ${e.toString()}", error: e, stackTrace: st);
}
return KResult.error(e.toString(), st, logError);
}
}