A util to help trace errors
Using npm
:
npm i --save-dev @fizzygalacticus/trythis
Using yarn
:
yarn add --dev @fizzygalacticus/trythis
trythis
can be used on both asynchronous and synchronous functions:
synchronous:
trythis(() => `this shouldn't throw`)(/* ...params */);
trythis(() => {throw new Error('this should throw')})(/* ...params */);
asynchronous:
trythis(() => Promise.resolve(`this shouldn't throw`))(/* ...params */);
trythis(() => Promise.reject('this should throw'))(/* ...params */);