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

Allow to unwrap joined errors #858

Merged
merged 2 commits into from
Nov 4, 2023
Merged

Conversation

MaxShoshin
Copy link
Contributor

To support logic of processing inner errors

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

It is unable to enumerate inner errors without reflection.

Issue Number: N/A

What is the new behavior?

You can cast joinError to standard interface {Unwrap()[] error} And work with inner errors.

To support logic of processing inner errors
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (461b0fe) 66.25% compared to head (aff378f) 66.84%.
Report is 34 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #858      +/-   ##
==========================================
+ Coverage   66.25%   66.84%   +0.59%     
==========================================
  Files         253      255       +2     
  Lines       24004    24245     +241     
==========================================
+ Hits        15903    16206     +303     
+ Misses       7267     7209      -58     
+ Partials      834      830       -4     
Flag Coverage Δ
53.41% <100.00%> (+0.41%) ⬆️
go-1.17.x 65.20% <100.00%> (+0.28%) ⬆️
go-1.20.x 66.66% <100.00%> (+0.47%) ⬆️
go-1.21.x 66.60% <100.00%> (+0.52%) ⬆️
integration 53.41% <100.00%> (+0.41%) ⬆️
macOS 39.09% <100.00%> (-0.75%) ⬇️
ubuntu 39.10% <100.00%> (-0.76%) ⬇️
unit 39.18% <100.00%> (-0.77%) ⬇️
windows 39.12% <100.00%> (-0.78%) ⬇️
ydb-22.5 53.07% <100.00%> (+0.48%) ⬆️
ydb-23.1 53.00% <100.00%> (+0.29%) ⬆️
ydb-23.2 52.96% <100.00%> (+0.30%) ⬆️
ydb-23.3 53.19% <100.00%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
internal/xerrors/join.go 96.29% <100.00%> (+0.29%) ⬆️

... and 51 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

CHANGELOG.md Outdated
@@ -1,3 +1,4 @@
* Allow to Unwrap joined errors (internal/xerrors/join.go `joinError.Unwrap() []error`)
Copy link
Member

Choose a reason for hiding this comment

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

No need to add a line into CHANGELOG for internal refactorings

@@ -43,3 +43,8 @@ func (errs joinError) Is(target error) bool {
}
return false
}

func (errs joinError) Unwrap() []error {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a small test for this feature?

Copy link
Member

Choose a reason for hiding this comment

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

You can add file join_go1.20_test.go with build tags

//go:build go1.20
// +build go1.20

for testing true behaviour with standard package errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test added.

@MaxShoshin
Copy link
Contributor Author

@asmyasnikov , any updates?

@asmyasnikov asmyasnikov merged commit d98f854 into ydb-platform:master Nov 4, 2023
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants