Skip to content

Conversation

@schpetbot
Copy link
Collaborator

feat: user-friendly error messages with debug mode support

Add a centralized error handling module inspired by Rust's error handling
patterns (anyhow, thiserror) that provides:

  • Clean, user-friendly error messages by default
  • Stack traces only shown when LINEAR_DEBUG=1 (similar to RUST_BACKTRACE=1)
  • Specialized error types: CliError, NotFoundError, ValidationError, AuthError
  • GraphQL error message extraction from Linear API responses
  • handleError() function for consistent error display across commands

Update issue-relation command to use the new error handling:

  • Use ValidationError for invalid input
  • Use NotFoundError for missing issues/relations
  • All errors now show clean messages without stack traces by default

Fixes #116

@schpetbot schpetbot force-pushed the pr/929f950e branch 2 times, most recently from 864a057 to cfa368c Compare February 2, 2026 04:59
Fixes #116

Error messages are now clean and user-friendly by default. Stack traces
are only shown when LINEAR_DEBUG=1 is set, similar to RUST_BACKTRACE.

Changes:
- Add src/utils/errors.ts with error handling infrastructure:
  - CliError base class with user-facing messages and suggestions
  - NotFoundError for entity lookups
  - ValidationError for invalid input
  - AuthError for authentication issues
  - handleError() for consistent error display
  - extractGraphQLMessage() to parse Linear API errors
- Update all commands to use handleError() for consistent error display
- Error output goes to stderr with ✗ prefix
- GraphQL errors show userPresentableMessage when available

Example before:
  Error: Entity not found: Issue: {"response":{"data":null...

Example after:
  ✗ Issue not found: FAKE-9999
@schpet schpet merged commit 430ac04 into main Feb 2, 2026
8 checks passed
@schpet schpet deleted the pr/929f950e branch February 2, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error messages should be user-friendly, not stack traces

3 participants