Skip to content

Conversation

lukemassa
Copy link
Contributor

@lukemassa lukemassa commented Feb 8, 2025

what

Add nil checks before returning wrapped errors.

why

Partially in prep for #5269, since if we return fmt.Errorf("... : %w", err) when err is nil, it won't, as errors.Wrap(err, "...") does in this situation, return nil.

Additionally, I find that relying on errors.Wrap(err, "...") to return nil if err is nil a bit hard to read. It can also lead to subtle bugs like #5294 and #5312.

I also put a few errors that were split between lines onto one line, which is more specifically in prep for #5269 (which I am writing a script to do replacements for mechanically).

tests

Just running unit tests.

references

Cleaning up code to make #5269 a bit simpler (though I think this change is worth doing on its own).

Signed-off-by: Luke Massa <[email protected]>
Signed-off-by: Luke Massa <[email protected]>
@lukemassa lukemassa requested review from a team as code owners February 8, 2025 18:10
@lukemassa lukemassa requested review from GenPage, nitrocode and X-Guardian and removed request for a team February 8, 2025 18:10
@dosubot dosubot bot added go Pull requests that update Go code refactoring Code refactoring that doesn't add additional functionality labels Feb 8, 2025
@lukemassa lukemassa marked this pull request as draft February 8, 2025 18:18
Signed-off-by: Luke Massa <[email protected]>
@lukemassa lukemassa force-pushed the prep_pkg_error_replacement branch from d56721a to 37f5aa1 Compare February 8, 2025 18:19
Signed-off-by: Luke Massa <[email protected]>
@lukemassa lukemassa marked this pull request as ready for review February 8, 2025 18:24
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 10, 2025
@lukemassa lukemassa merged commit cf0b3f3 into runatlantis:main Feb 11, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code lgtm This PR has been approved by a maintainer provider/azuredevops provider/gitlab refactoring Code refactoring that doesn't add additional functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants