Skip to content

refactor(commands): standardize error handling with ContextError#20

Merged
betegon merged 4 commits intomainfrom
refactor/error-hierarchy
Jan 19, 2026
Merged

refactor(commands): standardize error handling with ContextError#20
betegon merged 4 commits intomainfrom
refactor/error-hierarchy

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Jan 19, 2026

Summary

Standardizes CLI command interfaces to match gh CLI conventions. Adds a ContextError class for consistent "missing context" errors and removes the redundant positional argument from project list.

Part of Issue #4: Command Pattern Improvements.

Changes

  • New ContextError class in lib/errors.ts for consistent error formatting
  • Removed positional org argument from project list (now --org flag only)
  • Updated all get commands to use ContextError instead of inline error strings
  • Added CONTRIBUTING.md documenting command patterns for contributors

Breaking Change

sentry project list <org> no longer works. Use sentry project list --org <org> instead.

Test plan

  • Unit tests pass (192 tests)
  • Source files pass lint
  • Manual test: sentry project list --org <org> works
  • Manual test: sentry org get without args shows ContextError format

🤖 Generated with Claude Code

betegon and others added 4 commits January 19, 2026 18:18
Add ContextError class for consistent "missing context" error messages
across all commands, following gh CLI patterns.

Changes:
- Add ContextError to error hierarchy in lib/errors.ts
- Remove positional arg from `project list` (breaking change)
- Update all get/list commands to use ContextError
- Update tests for new `--org` flag syntax

BREAKING CHANGE: `sentry project list <org>` no longer works.
Use `sentry project list --org <org>` instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documents the CLI command conventions for future contributors:
- List vs get command patterns
- Context resolution order (flags > config > DSN)
- Common flags reference
- ContextError usage for consistent errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update error messages to mention both auto-detection options:
- Run from a directory with a Sentry-configured project
- Set SENTRY_DSN environment variable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…constant

Add DEFAULT_CONTEXT_ALTERNATIVES constant in errors.ts and use it as
the default value for ContextError constructor. This removes repeated
alternatives arrays from 5 command files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@betegon betegon marked this pull request as ready for review January 19, 2026 17:39
@betegon betegon merged commit db7d1f1 into main Jan 19, 2026
2 checks passed
@betegon betegon deleted the refactor/error-hierarchy branch January 19, 2026 17:39
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.

1 participant