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

Introduce support for wrapped errors in the codebase #6041

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

3vilhamster
Copy link
Contributor

@3vilhamster 3vilhamster commented May 22, 2024

What changed?
I've switched all direct error handling to usage of either errors.Is or errors.As.
I've split the PR into commits so it can be reviewed commit by commit.
Most of the changes are converting expressions to an identical one so no logical changes are expected:

if _, ok := err.(*customErr); ok {

to

if errors.As(err, new(*customErr)) {

There were a couple of more complicated cases, but all could be resolved.

Why?
This is a mandatory step to improve existing error handling that does not provide a clear path of where the error is coming from. In all style guides, error wrapping is recommended, but the codebase should be ready to handle wrapped errors instead of exact type checks.

How did you test it?
Unit/integration tests.

Potential risks
Potentially, some errors could be misclassified.

Release notes

Documentation Changes

Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 57.21925% with 80 lines in your changes are missing coverage. Please review.

Project coverage is 68.14%. Comparing base (f8765f0) to head (91d2e19).

Additional details and impacted files
Files Coverage Δ
client/history/client.go 79.54% <100.00%> (+0.03%) ⬆️
common/archiver/historyIterator.go 81.48% <100.00%> (ø)
common/backoff/retry.go 89.77% <100.00%> (-0.12%) ⬇️
common/domain/handler.go 53.06% <100.00%> (-0.15%) ⬇️
common/dynamicconfig/config.go 93.47% <100.00%> (ø)
...n/dynamicconfig/configstore/config_store_client.go 68.68% <100.00%> (ø)
common/elasticsearch/client/v6/client_bulk.go 91.07% <100.00%> (ø)
common/elasticsearch/client/v7/client_bulk.go 90.82% <100.00%> (ø)
common/persistence/data_manager_interfaces.go 95.48% <100.00%> (-0.03%) ⬇️
common/persistence/nosql/nosql_execution_store.go 73.58% <100.00%> (ø)
... and 44 more

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8765f0...91d2e19. Read the comment docs.

Copy link
Contributor

@jakobht jakobht left a comment

Choose a reason for hiding this comment

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

There is a lot of places where I think we shoud prefer to use assert.ErrorAs insted of assert.True(t, errors.As.... Commented a few places, but not all

common/types/mapper/proto/errors.go Outdated Show resolved Hide resolved
common/types/mapper/thrift/errors.go Outdated Show resolved Hide resolved
@3vilhamster 3vilhamster force-pushed the wrapper-errors-support branch 3 times, most recently from f9b7afe to 35a729e Compare May 24, 2024 15:35
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.

None yet

2 participants