The
causedata property of an Error instance indicates the specific original cause of the error.:(c) MDN
🐊Putout plugin adds ability to apply cause
Checkout in 🐊Putout Editor.
npm i @putout/plugin-apply-cause
{
"rules": {
"apply-cause": "on"
}
}try {} catch(error) {
if (controller.signal.aborted)
throw Error('timeout');
}try {} catch(error) {
if (controller.signal.aborted)
throw Error('timeout', {
cause: error,
});
}| Linter | Rule | Fix |
|---|---|---|
| 🐊 Putout | apply-cause |
✅ |
| ⏣ ESLint | apply-cause |
❌ |
MIT