zarf-dev / zarf

DevSecOps for Air Gap & Limited-Connection Systems. https://zarf.dev/
Apache License 2.0
1.41k stars 171 forks source link

Linter for error wrapping #2906

Open schristoff opened 2 months ago

schristoff commented 2 months ago

In the effort to return better errors we need to make sure that we are wrapping errors properly. One part of it is that we wrap errors properly. This means using the correct format when wrapping errors fmt.Errorf("something else: %w", err). The other par is that we do not discard upstream errors when returning an error.

Errorlint should check for the correct format when enabled. It can miss certain cases which is why some manual verification needs to be done. https://golangci-lint.run/usage/linters/#errorlint

phillebaba commented 2 months ago

I have looked around and have not immediately found a way for a linter to check if the parent error has been discarded. It would be nice to have this but may not be possible.