safely function

dynamic safely(
  1. Function block
)

Execute block, ignoring any exceptions, merely logging them via logError.

Implementation

safely(Function block) {
  try {
    block();
  } catch (it, trace) {
    logError("safely failed - ignored: $it", trace);
  }
}