Conditional Catch
Catch me if you can
API
This module exports a class ConditionalCatch
which should only be created via the static function ConditionalCatch.createFrom(error: Error)
.
The returned object contains the following methods:
handle(conditionFn, thenFn)
: registers an condition checkhandleOrThrow()
: Executes all registered handlers and if none matches throws the error
Installation
npm install conditional-catch
Example
const ConditionalCatch = // ... try // some action that throws errors catch error ConditionalCatch ;