skpIf method

  1. @visibleForTesting
  2. @protected
void skpIf(
  1. bool condition,
  2. String reason, {
  3. Level level = Level.FINE,
})

if you want interrupt the normal flow, but not trigger runCatching.onFailure

condition true: throw SkipError with reason level Level.FINE, (default) will not print by default Logger.root.level = Level.INFO;

runCatching((){
  skpIf(true,'interrupt by xxx reason, and this is not failure'); // throw, but on catching
  return 'ok';
},
onFailure: (e,s){
  print('$e; $s'); // will not print SkipError
});

ref runCatching.ignoreSkipError

Implementation

@visibleForTesting
@protected
void skpIf(bool condition, String reason, {Level level = Level.FINE}) =>
    condition ? throw SkipError(reason, level: level.value) : null;