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

fix: Improve error wrapping #512

Closed
wants to merge 1 commit into from
Closed

fix: Improve error wrapping #512

wants to merge 1 commit into from

Conversation

yevgenypats
Copy link
Member

No description provided.

@github-actions github-actions bot added the fix label Dec 17, 2022
if err := eg.Wait(); err != nil {
return fmt.Errorf("got EOF. failed to wait for plugin: %w", err)
return fmt.Errorf("got EOF. plugin returned: %w", err)
Copy link
Member

@erezrokah erezrokah Dec 18, 2022

Choose a reason for hiding this comment

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

EOF is not an error necessarily (it usually means the stream was closed), so I'm not sure we want to report it (we can log it instead as Debug). Also to be consistent we should add plugin returned to everywhere we do eg.Wait(), like lines 105 and 114 in this file.

You can see https://github.com/cloudquery/plugin-sdk/pull/461/files for reference.

We can also reduce the nesting of handling EOF, but that can be done in another PR, see #463 for reference

case ch <- clientResource:
}
}

close(ch)
if err := eg.Wait(); err != nil {
return err
return fmt.Errorf("write client returned: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("write client returned: %w", err)
return fmt.Errorf("write client failed with error: %w", err)

Also shouldn't we use the same message above, i.e. instead plugin returned -> write failed

@erezrokah
Copy link
Member

An additional comment on this. gRPC doesn't support error wrapping, so using %w doesn't really have any value here. You can see an example in https://github.com/cloudquery/plugin-sdk/pull/487/files how to chain multiple errors

@yevgenypats
Copy link
Member Author

Closing as this was addressed in additional PR.

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 this pull request may close these issues.

2 participants