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

Wrap errors with more context #130

Closed
obitech opened this issue Feb 15, 2022 · 2 comments · Fixed by #132
Closed

Wrap errors with more context #130

obitech opened this issue Feb 15, 2022 · 2 comments · Fixed by #132

Comments

@obitech
Copy link
Contributor

obitech commented Feb 15, 2022

I think we could provide a bit more context around the returned errors. Right now there are a lot of these kind of error returns:

	if err := r.Create(ctx, newRule); err != nil {
		return ctrl.Result{}, err
	}

// ...

	if err := r.Update(ctx, newRule); err != nil {
		return ctrl.Result{}, err
	}

In this specific example it might not be immediately clear in the logs if an error occurred during the the Create or Update step.

My suggestion would be to wrap errors with minimal context.

@obitech
Copy link
Contributor Author

obitech commented Feb 15, 2022

Again, happy to provide a PR? 😌

@metalmatze
Copy link
Member

Yes, wrapping with fmt.Errorf("error: %w", err) sounds really good.
Logging might be a similar issue where sometimes it's missing context.

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

Successfully merging a pull request may close this issue.

2 participants