Awesome Reviewers

Reviewer · Error Handling

Deliberate error handling

Never swallow errors silently or let a caught exception disappear without a trace. When catching an error, either handle it meaningfully (log, surface to the caller, or recover) or let it propagate—don't use empty catch blocks that mask failures. If you only expect a specific, known failure (e.g. `ENOENT`, eval being unavailable), check for that specific...

Instruction

Never swallow errors silently or let a caught exception disappear without a trace. When catching an error, either handle it meaningfully (log, surface to the caller, or recover) or let it propagate—don’t use empty catch blocks that mask failures. If you only expect a specific, known failure (e.g. ENOENT, eval being unavailable), check for that specific condition and rethrow anything else:

try {
  unlinkSync(path);
} catch (err) {
  if (err.code !== 'ENOENT') {
    throw err; // don't swallow unexpected errors
  }
}

When wrapping or re-throwing an error, preserve the original failure as the cause so the root issue isn’t lost:

catch (error) {
  return {error: new Error('Failed to inspect hooks.', {cause: error})};
}

Let the caller decide how to react to a failure instead of unilaterally deciding to ignore it inside a low-level utility—return structured error information rather than hiding it.

Use try/finally to guarantee cleanup (releasing resources, deleting pending callbacks, closing connections) runs even when the guarded code throws, so failures don’t leak resources or leave state inconsistent.

When invoking multiple independent callbacks or user-supplied code from internal framework logic, wrap each invocation in its own try/catch so that one failing callback doesn’t prevent the others from running or corrupt subsequent processing.

Finally, failures that would silently produce a different (but plausible) result—such as a fallback path succeeding with degraded behavior—should be logged (console.error/warning) or fail the operation outright rather than being swallowed, so regressions are caught early instead of persisting unnoticed.