deno_lint logodeno_lint

All rules/no-ex-assign

no-ex-assign

Recommended

Disallows the reassignment of exception parameters

There is generally no good reason to reassign an exception parameter. Once reassigned the code from that point on has no reference to the error anymore.

Invalid:

try {
  someFunc();
} catch (e) {
  e = true;
  // can no longer access the thrown error
}

Valid:

try {
  someFunc();
} catch (e) {
  const anotherVar = true;
}