Back to all reviewers

Provide actionable error messages

nrwl/nx
Based on 2 comments
TypeScript

When handling errors, transform technical exceptions into user-friendly messages that include clear remediation steps and actionable guidance. Avoid exposing raw technical errors to users, and instead provide context about what went wrong and how to resolve the issue.

Error Handling TypeScript

Reviewer Prompt

When handling errors, transform technical exceptions into user-friendly messages that include clear remediation steps and actionable guidance. Avoid exposing raw technical errors to users, and instead provide context about what went wrong and how to resolve the issue.

Rather than letting technical errors bubble up:

try {
  isNpmInstalled = getPackageManagerVersion('npm', process.cwd(), true) !== '';
} catch (e) {
  throw e; // Raw technical error
}

Provide controlled, user-facing error messages:

try {
  isNpmInstalled = getPackageManagerVersion('npm', process.cwd(), true) !== '';
} catch (e) {
  console.error(`npm was not found in the current environment. This is only supported when using \`bun\` as a package manager, but your detected package manager is "${pm}"`);
  return { success: false };
}

Error messages should:

  • Explain what went wrong in user terms
  • Provide specific remediation steps when possible
  • Include relevant context (like detected package manager)
  • Mention alternative solutions or workarounds when appropriate
  • Guide users to additional resources for verification (e.g., “check the package at npmjs.org”)
2
Comments Analyzed
TypeScript
Primary Language
Error Handling
Category

Source Discussions