Use %w instead of %v in fmt.Errorf for proper error wrapping#42
Merged
JamieMagee merged 1 commit intomainfrom Feb 10, 2026
Merged
Use %w instead of %v in fmt.Errorf for proper error wrapping#42JamieMagee merged 1 commit intomainfrom
JamieMagee merged 1 commit intomainfrom
Conversation
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.
jpinz
approved these changes
Feb 10, 2026
There was a problem hiding this comment.
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.goto use%winstead of%vfor proper error wrapping
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.
The
errorlintlinter flagged a non-wrapping format verb incollector_client.go. The call tofmt.Errorfused%v, which stringifies the error and discards the original error value. Switching to%wwraps it instead, so callers can inspect the underlying error witherrors.Isanderrors.As.