Skip to content

Use %w instead of %v in fmt.Errorf for proper error wrapping#42

Merged
JamieMagee merged 1 commit intomainfrom
jamiemagee/fix-errorlint
Feb 10, 2026
Merged

Use %w instead of %v in fmt.Errorf for proper error wrapping#42
JamieMagee merged 1 commit intomainfrom
jamiemagee/fix-errorlint

Conversation

@JamieMagee
Copy link
Copy Markdown
Member

The errorlint linter flagged a non-wrapping format verb in collector_client.go. The call to fmt.Errorf used %v, which stringifies the error and discards the original error value. Switching to %w wraps it instead, so callers can inspect the underlying error with errors.Is and errors.As.

The errorlint linter flagged a non-wrapping format verb in
collector_client.go. Switching from %v to %w lets callers
inspect the underlying error with errors.Is and errors.As.
Copilot AI review requested due to automatic review settings February 10, 2026 21:41
@JamieMagee JamieMagee enabled auto-merge (squash) February 10, 2026 21:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling by using proper error wrapping in the metrics collection code. The change switches from %v to %w in a fmt.Errorf call, enabling callers to inspect the underlying error using standard Go error inspection functions like errors.Is and errors.As.

Changes:

  • Updated error formatting in collector_client.go to use %w instead of %v for proper error wrapping

@JamieMagee JamieMagee merged commit b05fdd0 into main Feb 10, 2026
11 of 13 checks passed
@JamieMagee JamieMagee deleted the jamiemagee/fix-errorlint branch February 10, 2026 21:43
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.

3 participants