runCatching<T> function
运行,内置捕获函数,有返回
Implementation
T? runCatching<T>(T Function() runnable, [T? Function(CatchException e)? onFailure]) {
try {
return runnable.call();
} on Error catch (e) {
return onFailure?.call(CatchException(e, null));
} on Exception catch (e) {
return onFailure?.call(CatchException(null, e));
}
}