try-catch-fn
v1.0.2
Published
Functional JavaScript try-catch implementation
Downloads
10
Readme
try-catch-fn
Functional try-catch implementation.
More info here: This is how functional try-catch transforms your JavaScript code.
Usage
import { tryCatch } from 'try-catch-fn';
const status = tryCatch({
tryFn: () => {
throw new Error('network error');
},
catchFn: (err) => 'error',
});
console.log(status); // error
Pass single function argument to simply "silence" any exception it throws.
import { tryCatch } from 'try-catch-fn';
const status = tryCatch(() => {
throw new Error('error');
});
console.log(status); // null