cleanup: use %w instead of %v for error wrapping in fmt.Errorf - #1640
cleanup: use %w instead of %v for error wrapping in fmt.Errorf#1640safiya2610 wants to merge 2 commits into
Conversation
Signed-off-by: safiya2610 <lci2023053@iiitl.ac.in>
c541dd0 to
301e8c4
Compare
|
If you don't perform subsequent handling of the returned error using |
+1 |
|
How can we ensure that all future code consistently uses %w instead of %v? Or we need to perform a periodic fix? |
Signed-off-by: safiya2610 <lci2023053@iiitl.ac.in>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
To ensure that all future code consistently uses |
Even though errors.Is() and errors.As() are not currently used in these places, my intention was to preserve the original error so it can be handled properly if needed in the future. |
I have done this using Ctrl+ shift+H, and perform replacement.
This PR systematically replaces
fmt.Errorf("... %v", err)withfmt.Errorf("... %w", err)across the codebase. Using%wcorrectly wraps the error in Go 1.13+, preserving the original error type and allowing upstream functions to properly inspect it usingerrors.Is()anderrors.As().Fixes #1639