Skip to content

feat: add structured CLI errors with distinct exit codes#90

Merged
steve-calvert-glean merged 1 commit into
mainfrom
structured-cli-errors
Apr 12, 2026
Merged

feat: add structured CLI errors with distinct exit codes#90
steve-calvert-glean merged 1 commit into
mainfrom
structured-cli-errors

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Collaborator

Summary

  • Introduces CLIError type in internal/errors/ carrying user message, suggestion, exit code, and cause
  • Exit code constants: auth (3), network (4), API (5), rate-limited (6), timeout (7)
  • authError() in cmd/root.go now returns a CLIError instead of printing to stderr + returning errSilent
  • Execute() and main.go extract exit codes from CLIError

Test plan

  • Unit test: CLIError.Error() with and without suggestion
  • Unit test: Unwrap() returns cause
  • Unit test: errors.As works with CLIError
  • mise run test:all passes (455 tests, lint clean, binary builds)

Introduces CLIError type carrying user message, suggestion, exit code,
and cause. Scripts wrapping glean can now distinguish auth failures
(exit 3) from network errors (exit 4) from API errors (exit 5).
Converts authError() to use CLIError as the first adopter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner April 11, 2026 21:03
@steve-calvert-glean steve-calvert-glean added the enhancement New feature or request label Apr 12, 2026
@steve-calvert-glean steve-calvert-glean merged commit 58bc2ad into main Apr 12, 2026
7 checks passed
@steve-calvert-glean steve-calvert-glean deleted the structured-cli-errors branch April 12, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants