skpIf method

  1. @visibleForTesting
  2. @protected
void skpIf(
  1. bool condition,
  2. String reason
)

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

condition true: throw SkipError with reason

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) =>
    condition ? throw SkipError(reason) : null;