Awesome Reviewers

When catching errors from syscalls, spawned processes, or optional APIs, never collapse distinct failure modes into one generic catch. Check the specific error code/condition and handle only the exact case you mean to special-case; let anything else either propagate or be reported with its own precise status, instead of silently mapping it onto an unrelated outcome.

Concretely:

Example pattern:

try {
  await fs.promises.stat(path);
} catch (error) {
  if (error?.code === "ENOENT" || error?.code === "ENOTDIR") {
    return { status: "missing" };
  }
  // Don't swallow EACCES/EIO/etc. as "missing" — report distinctly.
  return { status: "inaccessible", error };
}

Applying this discipline prevents misleading outcomes (e.g. reporting “no hook” when a hook exists but is unreadable, or crashing on an unrelated race) and makes error messages and recovery behavior accurate and actionable.