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

Refactor and improve error struct #891

Open
srijan-27 opened this issue Aug 5, 2024 · 0 comments
Open

Refactor and improve error struct #891

srijan-27 opened this issue Aug 5, 2024 · 0 comments
Labels
Datasource enhancement New feature or request

Comments

@srijan-27
Copy link
Contributor

          Now, the code is clearer to me. Thanks for the changes by the way.

I would like to suggest something that would make more sense according to me

Here the code relies (and already relied) on something that single purpose could be defined by these:

  • we need to be able to catch this error
  • we want to provide a meaningful error message that will contain the kind.

The current way is OK, but somehow overkill

Here is what I would code if I had to.

We don't define a struct, we define a simple sentinel error. This will ensure we can catch the error with a simple errors.Is

var ErrUnexpectedPointer = errors.New("unexpected pointer")

Then we use fmt.Errorf("%w to %s", ErrUnexpectedPointer, rv.Kind.String()) here

I know code was there, I know I'm asking to change something you are not responsible for. But, I report what I would have expected here.

As the errors are now exported, I would expect them to be clean.

Please let me know what you think about it

Originally posted by @ccoVeille in #860 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datasource enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant