This rule disallows the try
keyword.
Try statements are not part of functional programming. See no-throw-statement for more information.
Examples of incorrect code for this rule:
/* eslint functional/no-try-statement: "error" */
try {
doSomethingThatMightGoWrong(); // <-- Might throw an exception.
} catch (error) {
// Handle error.
}
Examples of correct code for this rule:
/* eslint functional/no-try-statement: "error" */
doSomethingThatMightGoWrong() // <-- Returns a Promise.
.catch((error) => {
// Handle error.
});
This rule accepts an options object of the following type:
{
allowCatch: boolean;
allowFinally: boolean;
}
The default options:
{
allowCatch: false,
allowFinally: false
}
If true, try-catch statements are allowed.
If true, try-finally statements are allowed.