Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple: detect errors created just for logging #728

Open
ainar-g opened this issue Apr 13, 2020 · 3 comments
Open

simple: detect errors created just for logging #728

ainar-g opened this issue Apr 13, 2020 · 3 comments
Labels
new-check started Issues we've started working on

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Apr 13, 2020

Another from an old project of mine. Code like this:

log.Print(errors.New("oh no"))
log.Print(fmt.Errorf("oh no: %w", err))

Should really be this:

log.Print("oh no")
log.Printf("oh no: %s", err)

Same with testing helpers.

@ainar-g ainar-g added the needs-triage Newly filed issue that needs triage label Apr 13, 2020
@dominikh dominikh added needs-decision We have to decide if this check is feasible and desirable new-check and removed needs-triage Newly filed issue that needs triage labels Apr 13, 2020
@ainar-g
Copy link
Contributor Author

ainar-g commented Apr 14, 2020

This is very similar to #143.

@dominikh dominikh removed the needs-decision We have to decide if this check is feasible and desirable label Apr 15, 2020
@dominikh
Copy link
Owner

Weirdest offender I've found today: panic(fmt.Errorf("...")) (yes, there were no format specifiers in the string.)

@ainar-g
Copy link
Contributor Author

ainar-g commented Jan 15, 2021

That one might actualy sort of make sense if there is a panic handler upstack that distinguishes between error and non-error recover return-values. Although in this particular case one would probably just use errors.New.

@dominikh dominikh added the started Issues we've started working on label Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-check started Issues we've started working on
Projects
None yet
Development

No branches or pull requests

2 participants