refactor(commands): standardize error handling with ContextError#20
Merged
refactor(commands): standardize error handling with ContextError#20
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Standardizes CLI command interfaces to match gh CLI conventions. Adds a
ContextErrorclass for consistent "missing context" errors and removes the redundant positional argument fromproject list.Part of Issue #4: Command Pattern Improvements.
Changes
ContextErrorclass inlib/errors.tsfor consistent error formattingproject list(now--orgflag only)getcommands to useContextErrorinstead of inline error stringsCONTRIBUTING.mddocumenting command patterns for contributorsBreaking Change
sentry project list <org>no longer works. Usesentry project list --org <org>instead.Test plan
sentry project list --org <org>workssentry org getwithout args shows ContextError format🤖 Generated with Claude Code