Skip to content

exceptionAssignments

Reports reassigning exception parameters in catch clauses.

✅ This rule is included in the ts logical preset.

Reassigning an exception parameter in a catch clause can make debugging more difficult by obscuring the original error. The exception parameter contains important information about what went wrong, and reassigning it makes it harder to understand the root cause of an error.

try {
processData();
} catch (error) {
error = new Error("Processing failed");
throw error;
}
try {
validateInput();
} catch (exception) {
exception = null;
console.log(exception);
}

This rule is not configurable.

If you’re working in an existing codebase where reassigning exception parameters is an established pattern and refactoring would be too costly, you might choose to disable this rule. However, this is generally not recommended as it can make code harder to debug and maintain.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.