Use try-catch statements in a more convenient way with this package.
yarn add @orlovsky/try-catchor
npm i @orlovsky/try-catchimport { tryCatch } from '@orlovsky/try-catch';
// ...
const [error, result] = tryCatch(() => someFnThatMayThrow());
if (error) {
// do something with error
return;
}
// do something with resultInspired by try-catch.
Created with typescript-library-starter.