feat: add sentinel errors and typed errors for programmatic error handling#4
Merged
christiangda merged 3 commits intomainfrom Feb 14, 2026
Merged
feat: add sentinel errors and typed errors for programmatic error handling#4christiangda merged 3 commits intomainfrom
christiangda merged 3 commits intomainfrom
Conversation
…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>
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
errors.go: Consolidates all error definitions. Adds 3 new sentinel errors (ErrNotFound,ErrOEMPlaceholder,ErrAllMethodsFailed) and 3 typed errors (CommandError,ParseError,ComponentError)machineid.go:DiagnosticInfo.Errorsentries are now wrapped inComponentError, enablingerrors.As()inspectionexecutor.go: Command failures return*CommandErrorwith the command namedarwin.go/linux.go/windows.go: All ad-hocerrors.New()calls replaced with sentinel-wrappingfmt.Errorf("...: %w", ErrXxx)or typed errors (&ParseError{...})errors_test.go: Comprehensive tests forError(),Unwrap(),errors.Is(),errors.As(), and deep wrapping chainsdoc.go: New "Errors" section documenting all sentinel and typed errorsTest plan
go build ./...passesgo vet ./...cleango test -v -race -count=1 ./...— all 90+ tests passerrors.Is(err, ErrNotFound)works through wrapping chainserrors.As(err, &CommandError{})extracts command nameDiagnosticInfo.Errorsvalues supporterrors.As(&ComponentError{})🤖 Generated with Claude Code