Skip to content

Improve error messages by adding helpful context #1836

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

Closed
douglascamata opened this issue Apr 8, 2025 · 3 comments
Closed

Improve error messages by adding helpful context #1836

douglascamata opened this issue Apr 8, 2025 · 3 comments

Comments

@douglascamata
Copy link

douglascamata commented Apr 8, 2025

Is your feature request related to a problem? Please describe.

I'm currently trying to debug an issue when running github.com/shirou/gopsutil/v4/host.Info() in a Windows 2019 k8s node and for some reason it fails (I could already figure out the reason, but it's not the focus here). The error message is short and not helpful:

The system cannot find the file specified.

There's no information about which one of the InfoStat fields caused the issue and which file cannot be found.

Describe the solution you'd like

I would like the error to provide all the additional context related to the error. For example, if the problem happens when trying to fill in the InfoStat.KernelVersion field:

KernelVersion: the system cannot find the file "<whatever file it tried to find>"

Describe alternatives you've considered

None so far.

Additional context

None so far.

@s0ders
Copy link
Contributor

s0ders commented Apr 17, 2025

Working on a refactor (on the host package) to use fmt.Errorf on some key error returns to add some textual context in order to make error messages more helpful.

@s0ders
Copy link
Contributor

s0ders commented Apr 19, 2025

The PR has been merged, I believe this should fix your issue @douglascamata

@douglascamata
Copy link
Author

@s0ders thank you!

@shirou shirou closed this as completed Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants