$ cnpm install @putout/plugin-apply-try-catch
????Putout plugin adds ability to apply tryCatch and tryToCatch. Renamed to @putout/plugin-try-catch.
npm i @putout/plugin-apply-try-catch
{
"rules": {
"apply-try-catch/await": "on",
"apply-try-catch/args": "on",
"apply-try-catch/declare": "on",
"apply-try-catch/expand-arguments": "on",
"apply-try-catch/try-catch": "on",
"apply-try-catch/try-to-catch": "on"
}
}
try {
log('hello');
} catch(error) {
}
import tryCatch from 'try-catch';
const [error] = tryCatch(log, 'hello');
try {
await send('hello');
} catch(error) {
}
import tryToCatch from 'try-catch';
const [error] = await tryToCatch(send, 'hello');
await tryCatch(a, b);
tryToCatch(a, b);
await tryToCatch(a, b);
tryCatch(send('hello'));
tryCatch(send, 'hello');
const [error] = tryCatch(fs.readFileSync, 'hello.txt');
import tryCatch from 'try-catch';
const [error] = tryCatch(fs.readFileSync, 'hello.txt');
import tryCatch from 'try-catch';
test('some message', (t) => {
const fn = () => copymitter('/hello');
const [error] = tryCatch(fn);
t.equal(error.message, 'to should be a string!');
t.end();
});
import tryCatch from 'try-catch';
test('some message', (t) => {
const [error] = tryCatch(copymitter, '/hello');
t.equal(error.message, 'to should be a string!');
t.end();
});
MIT
Copyright 2013 - present © cnpmjs.org | Home |