Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Use fmt.Errorf instead of errors.Wrap where error handling make sense #831

Merged
merged 2 commits into from
Aug 24, 2020

Conversation

invidian
Copy link
Member

This commit partially addresses issue #59, which encourages to use new
error wrapping semantics available since Go 1.13, using %w formating
verb instead of 3rd party 'pkg/errors' package.

This commit changes errors handling code from using errors.Wrap with
fmt.Errorf where error handling should remain as is. For other uses of
errors.Wrap, it adds a comment with TODO how code should be changed to
either avoid or delegate error handling to someone else.

Signed-off-by: Mateusz Gozdek mateusz@kinvolk.io

@ipochi
Copy link
Member

ipochi commented Aug 24, 2020

Isn't @johananl changing those in the files related to platform package as part of his refactoring PR ?

@invidian
Copy link
Member Author

Isn't @johananl changing those in the files related to platform package as part of his refactoring PR ?

I'm not sure how is this related. The platform package refactoring PR is not even opened yet, but still it's focus would be different.

@knrt10
Copy link
Member

knrt10 commented Aug 24, 2020

@invidian should we add //TODOs in the same commit?

@invidian
Copy link
Member Author

invidian commented Aug 24, 2020

@invidian should we add //TODOs in the same commit?

I can't come up with any pro or con for committing it separately vs committing it together, maybe except that doing it together is a bit less work. So I'm not sure 😄

Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit. Rest LGTM!

@invidian invidian force-pushed the invidian/errors-wrap branch from 210270f to f3b9137 Compare August 24, 2020 08:16
@invidian invidian requested a review from knrt10 August 24, 2020 08:17
knrt10
knrt10 previously approved these changes Aug 24, 2020
Copy link
Member

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

Copy link
Member

@johananl johananl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Added some comments.

@invidian
Copy link
Member Author

Thanks for reviewing @johananl, I addressed all your comments, please have a look again.

johananl
johananl previously approved these changes Aug 24, 2020
Copy link
Member

@johananl johananl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found two missing periods. LGTM otherwise.

This commit partially addresses issue #59, which encourages to use new
error wrapping semantics available since Go 1.13, using %w formatting
verb instead of 3rd party 'pkg/errors' package.

This commit changes errors handling code from using errors.Wrap with
fmt.Errorf where error handling should remain as is. For other uses of
errors.Wrap, it adds a comment with TODO how code should be changed to
either avoid or delegate error handling to someone else.

This commit also changes error phrasing to the format we agreed in #59.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
Our codebase and vendor/ directory prefers 'marshaling' over
'marshalling', so this commit changes last remaining occurence of
unmarshalling to be consistent with rest of the error messages.

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
@invidian invidian merged commit ba0da58 into master Aug 24, 2020
@invidian invidian deleted the invidian/errors-wrap branch August 24, 2020 14:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants