RMD032 — More than one @catchError on a component
class Panel extends Component {
@catchError logIt(e: unknown) { report(e); }
@catchError showFallback() { this.failed = true; } // reported: the first never runs
render() { … }
}
A component has one answer to "who handles an error from below?", so one of them gets it; the others never run, and nothing says so — you read a handler that is dead.
The one that runs is the LOWEST, showFallback above. One rule covers this and
RMD040: the declaration applied last
is the one that stands. @catchError is a member decorator and members initialise top to bottom,
so the lowest is applied last. A class decorator applies bottom-up, so there it is the highest —
the same rule, the opposite line.
Keep one, and let it decide. It receives the error, and returning false declines it, so the
next component above with a handler takes over:
@catchError handle(e: unknown) {
// Not mine — let the boundary above have it.
if (!(e instanceof RangeError)) return false;
this.failed = e.message;
}
A subclass declaring its own is not this. That is an override: the subclass's handler replaces the base's, which is how a specialised boundary is written, and it is not reported. This fires only for two declarations on the same class.
Next
- All diagnostics — every code the framework can report.
- Checking your app — the faults proved from the source, before anything runs.