GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs: clarify preserve-caught-error known limitation (#21294) · eslint/eslint@5997825

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/src/rules
    • preserve-caught-error.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/src/rules/preserve-caught-error.md‎

Copy file name to clipboardExpand all lines: docs/src/rules/preserve-caught-error.md
+16-16Lines changed: 16 additions & 16 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -270,32 +270,32 @@ try {
270270

271271
## Known Limitations
272272

273-
This rule identifies custom error classes strictly by their name in the AST. Because it does not trace scope or type information, local shadowing will cause false positives.
273+
The `errorClassNames` option accepts names, not references to specific error classes. The rule matches these configured names in the AST and does not resolve scope or type information.
274274

275-
If a configured error class is shadowed by a local declaration, the rule will still flag it, even if the local class has a different signature and does not accept a `cause` option.
275+
As a result, a local class can shadow the intended error class while having the same name. The rule cannot distinguish the local class from the intended class and may report a false positive.
276276

277-
Example of a false positive:
277+
For example:
278278

279279
```js
280280
/* eslint preserve-caught-error: ["error", { errorClassNames: ["AppError"] }] */
281281

282282
function makeWrapped() {
283-
// Local class shadows the intended global/imported "AppError"
284-
class AppError {
285-
constructor(err) {
286-
this.original = err;
287-
}
288-
}
289-
290-
try {
291-
doSomething();
292-
} catch (err) {
293-
// Falsely reported as "missingCause" despite the local signature not accepting options
294-
throw new AppError(err);
295-
}
283+
class AppError {
284+
constructor(err) {
285+
this.original = err;
286+
}
287+
}
288+
289+
try {
290+
doSomething();
291+
} catch (err) {
292+
throw new AppError(err);
293+
}
296294
}
297295
```
298296

297+
Here, `AppError` is configured by name, but the local `AppError` class is different from the intended global/imported class. The rule still matches the name and may report a missing `cause`, even though this local class has a different constructor signature and does not accept an options object containing `cause`.
298+
299299
## When Not To Use It
300300

301301
You might not want to enable this rule if:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.