Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Modernize error handling #21

Merged
merged 4 commits into from
Mar 14, 2021
Merged

Modernize error handling #21

merged 4 commits into from
Mar 14, 2021

Conversation

tzdybal
Copy link
Member

@tzdybal tzdybal commented Feb 27, 2021

  • more idiomatic approach to errors (var instead of struct)
  • use errors.Is, as it's preferred way to check errors in go 1.13+

Reference: https://blog.golang.org/go1.13-errors

@tzdybal tzdybal requested review from musalbas and liamsi February 27, 2021 21:49
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

LGTM and I approve of these changes!

In fact, I made similar suggestions a while ago:

Back then @musalbas preferred to keep the error handling like before. Hence, I'd rather have him approve/decline the changes.

.travis.yml Outdated
@@ -1,4 +1,6 @@
language: go
go:
- 1.14.x
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason 1.14.x is used here instead of 1.15.x?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there is a particular reason. My suggestion would be to update it to 1.16 unless we want to also test backwards compatibility to old go versions. Then we could add them too. Either way, 1.16 should be in there.

Copy link
Member Author

Choose a reason for hiding this comment

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

No reason. Actually I'm going to merge #23, to it doesn't matter anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I remember - the reason was, go.mod is using 1.14.

Copy link
Member

Choose a reason for hiding this comment

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

Ah that makes sense. Unrelated to the current PR, what are the ramifications of updating go.mod to 1.15 or 1.16? cc @liamsi too

Copy link
Member

@liamsi liamsi Mar 12, 2021

Choose a reason for hiding this comment

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

As far as I remember this would simply indicate that we are using language features that were introduced with 1.16 (or whatever will be used in go.mod) and that we do not plan to support version smaller than the one listed in go.mod.
Btw, these versions do not necessarily need to match (the one in go.mod and the one used for travis). The one in go.mod could be lower. In the IPFS Plugin case, I wanted all versions to match because the plug-in used some x/system package which caused problems. I don't think that's a problem here.

* more idiomatic approach to errors (var instead of struct)
* use errors.Is, as it's preferred way to check errors in go 1.13+

See: https://blog.golang.org/go1.13-errors
@tzdybal tzdybal force-pushed the tzdybal/modern_errors branch from 213066e to da27ff7 Compare March 10, 2021 21:18
@@ -26,7 +26,7 @@ jobs:
go.mod
go.sum
- name: install
run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
run: GOOS=linux GOARCH=${{ matrix.goarch }} go build
Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow we missed this during all reviews and testing 😂

@tzdybal
Copy link
Member Author

tzdybal commented Mar 10, 2021

@musalbas please make a final decision (see: #21 (review))

@musalbas
Copy link
Member

Isn't this the wrong naming convention for sentinel value based errors? From the docs you linked, sentinel values start with Err.

Copy link
Member

@musalbas musalbas left a comment

Choose a reason for hiding this comment

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

Naming for errors should use Go naming convention

@tzdybal tzdybal requested a review from musalbas March 12, 2021 19:30
@musalbas musalbas merged commit 06cbf79 into master Mar 14, 2021
@adlerjohn adlerjohn deleted the tzdybal/modern_errors branch March 14, 2021 18:16
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