{"_id":"@putout/plugin-try-catch@8.2.0","tag":false,"bugs":{"url":"https://github.com/coderaiser/putout/issues"},"dist":{"shasum":"4ed78f9f886e15d02950de94a40cc7a0329d9100","tarball":"http://registry-npm.ywwl.com/@putout/plugin-try-catch/download/@putout/plugin-try-catch-8.2.0.tgz","fileCount":12,"integrity":"sha512-QbAhaeZjhIMm9FG2QG1YTnuLux3nb3aH1LCfdPA7QRbsU9ofv89aNGgw6xsGaYxiDPlV3GrnCjjQp7aH1E5BkA==","signatures":[{"sig":"MEQCIGLRWzk8MFvZ+i3u5qoC/RhcgetLbClAcpv37HZ0YN+AAiANx17V+IhrkNIkNi4ZHsBYuZBXEK4j9S+XDDPYEH5O+A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDpMmszLOdJAyfqwfjjeqh3fr1SNz6Olto1t2hX8acK8QIgPfhkjDxmV4Nxbc1BWUC4X2maXibzwcyrNoPQMZ16k3U="}],"unpackedSize":14220,"size":4390,"noattachment":false,"key":"/@putout/plugin-try-catch/-/@putout/plugin-try-catch-8.2.0.tgz"},"main":"lib/index.js","name":"@putout/plugin-try-catch","type":"module","author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"engines":{"node":">=22"},"gitHead":"a7ef1e5d5e0d014052b12fbc59dbfe8d494754a5","license":"MIT","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"version":"8.2.0","_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-try-catch#readme","keywords":["putout","putout-plugin","plugin","try-catch","try-to-catch"],"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"12.0.2","description":"🐊Putout plugin adds ability to apply try-catch","directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_nodeVersion":"26.12.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.0.0","madrun":"^13.0.0","nodemon":"^3.0.1","superc8":"^12.0.0","@putout/test":"^15.0.0","@putout/eslint-flat":"^4.0.0","eslint-plugin-putout":"^31.0.0"},"peerDependencies":{"putout":">=42"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-try-catch_8.2.0_1792701153374_0.007961081951282756"},"readme":"# @putout/plugin-try-catch [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-try-catch.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-try-catch \"npm\"\n\n> The `try...catch` statement marks a `try` block and a `catch` block. If the code in the `try` block throws an exception then the code in the `catch` block will be executed.\n>\n> (c) MDN\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds support of:\n\n- ✅ [try-catch](https://github.com/coderaiser/try-catch)\n- ✅ [try-to-catch](https://github.com/coderaiser/try-to-catch)\n\nWhich are drastically simplifies [`try...catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) blocks.\n\n## Install\n\n```\nnpm i @putout/plugin-try-catch\n```\n\n## Rules\n\n- ✅ [apply-destructuring](#apply-destructuring);\n- ✅ [args](#args);\n- ✅ [async](#async);\n- ✅ [await](#await);\n- ✅ [declare](#declare);\n- ✅ [expand-args](#expand-args);\n- ✅ [sync](#sync);\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"try-catch/await\": \"on\",\n        \"try-catch/args\": \"on\",\n        \"try-catch/apply-destructuring\": \"on\",\n        \"try-catch/declare\": \"on\",\n        \"try-catch/expand-args\": \"on\",\n        \"try-catch/sync\": \"on\",\n        \"try-catch/async\": \"on\"\n    }\n}\n```\n\n## apply-destructuring\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3356a8971b6ef8dcc7f35d09f0670576/6690425625bfa8df47db2e9afdd3e7490e15c6c0).\n\n### ❌ Example of incorrect code\n\n```js\nimport {tryCatch} from 'try-catch';\nimport {tryToCatch} from 'try-to-catch';\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\nimport {tryToCatch} from 'try-to-catch';\n```\n\n## args\n\n### ❌ Example of incorrect code\n\n```js\ntryCatch(send('hello'));\n```\n\n### ✅ Example of correct code\n\n```js\ntryCatch(send, 'hello');\n```\n\n## async\n\n### ❌ Example of incorrect code\n\n```js\ntry {\n    await send('hello');\n} catch(error) {}\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryToCatch} from 'try-catch';\n\nconst [error] = await tryToCatch(send, 'hello');\n```\n\n## await\n\n### ❌ Example of incorrect code\n\n```js\nawait tryCatch(a, b);\ntryToCatch(a, b);\n```\n\n### ✅ Example of correct code\n\n```js\nawait tryToCatch(a, b);\n```\n\n## declare\n\n### ❌ Example of incorrect code\n\n```js\nconst [error] = tryCatch(fs.readFileSync, 'hello.txt');\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error] = tryCatch(fs.readFileSync, 'hello.txt');\n```\n\n## expand-args\n\n### ❌ Example of incorrect code\n\n```js\nimport {tryCatch} from 'try-catch';\n\ntest('some message', (t) => {\n    const fn = () => copymitter('/hello');\n    const [error] = tryCatch(fn);\n    \n    t.equal(error.message, 'to should be a string!');\n    t.end();\n});\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\ntest('some message', (t) => {\n    const [error] = tryCatch(copymitter, '/hello');\n    \n    t.equal(error.message, 'to should be a string!');\n    t.end();\n});\n```\n\n## sync\n\n### ❌ Example of incorrect code\n\n```js\ntry {\n    log('hello');\n} catch(error) {}\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error] = tryCatch(log, 'hello');\n```\n\n## License\n\nMIT\n","publish_time":1792701153455,"_cnpm_publish_time":1792701153455,"dist-tags":{"latest":"8.2.0"}}