Skip to content

feat: add sentinel errors and typed errors for programmatic error handling#4

Merged
christiangda merged 3 commits intomainfrom
feat/sentinel-typed-errors
Feb 14, 2026
Merged

feat: add sentinel errors and typed errors for programmatic error handling#4
christiangda merged 3 commits intomainfrom
feat/sentinel-typed-errors

Conversation

@christiangda
Copy link
Contributor

Summary

  • New file errors.go: Consolidates all error definitions. Adds 3 new sentinel errors (ErrNotFound, ErrOEMPlaceholder, ErrAllMethodsFailed) and 3 typed errors (CommandError, ParseError, ComponentError)
  • machineid.go: DiagnosticInfo.Errors entries are now wrapped in ComponentError, enabling errors.As() inspection
  • executor.go: Command failures return *CommandError with the command name
  • darwin.go / linux.go / windows.go: All ad-hoc errors.New() calls replaced with sentinel-wrapping fmt.Errorf("...: %w", ErrXxx) or typed errors (&ParseError{...})
  • errors_test.go: Comprehensive tests for Error(), Unwrap(), errors.Is(), errors.As(), and deep wrapping chains
  • doc.go: New "Errors" section documenting all sentinel and typed errors

Test plan

  • go build ./... passes
  • go vet ./... clean
  • go test -v -race -count=1 ./... — all 90+ tests pass
  • errors.Is(err, ErrNotFound) works through wrapping chains
  • errors.As(err, &CommandError{}) extracts command name
  • DiagnosticInfo.Errors values support errors.As(&ComponentError{})

🤖 Generated with Claude Code

christiangda and others added 3 commits February 14, 2026 19:42
…dling

Introduce structured error types (CommandError, ParseError, ComponentError)
and new sentinel errors (ErrNotFound, ErrOEMPlaceholder, ErrAllMethodsFailed)
so callers can use errors.Is() and errors.As() to programmatically inspect
failure causes. DiagnosticInfo.Errors now wraps all entries in ComponentError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… CLI logger flags

Replace all remaining fmt.Errorf calls with typed errors (ParseError,
CommandError) and sentinel errors for programmatic error handling via
errors.Is/errors.As. Add missing logging to silent fallback paths and
file reads across darwin, linux, and windows collectors. Expose the
library logger in the CLI with -verbose and -debug flags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@christiangda christiangda self-assigned this Feb 14, 2026
@christiangda christiangda merged commit ee47b85 into main Feb 14, 2026
5 checks passed
@christiangda christiangda deleted the feat/sentinel-typed-errors branch February 14, 2026 19:04
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

Comments