Improving some internal error-handling #846
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to set us up to improve visibility into errors being returned by kafka-go by wrapping those errors before bubbling them up throughout the call stack. The hope is that by making each error into a clear chain, it should be much easier to troubleshoot by narrowing in on the most relevant branch of code that is failing.
To start towards this more lofty goal, the first step (and the main focus of this PR) is to replace "strict" error-checking (eg:
err == io.EOF
) with more modern/flexible checks (eg:errors.Is(err, io.EOF)
). This will allows us to freely wrap errors internally while not changing any error-handling logic at higher levels. Without this, blindly wrapping errors could result in subtle bugs as the older methods of checking errors would no longer behave the same way.While I did include some error-wrapping changes, the changes are pretty focused on the error-checking instead, which is already a decent size PR. We can use subsequent PRs to refactor other components (eg: reader, writer) and catch any other error-checking places I may have missed.