-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: join error #26
feat: join error #26
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26 +/- ##
==========================================
+ Coverage 86.33% 86.51% +0.18%
==========================================
Files 4 4
Lines 556 586 +30
==========================================
+ Hits 480 507 +27
- Misses 72 73 +1
- Partials 4 6 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
// Join returns an error that wraps the given errors. | ||
func Join(errs ...error) error { | ||
internal := errors.Join(errs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break eris.Is
's behavior, which I'm not so sure.
Caller can be easily mistaken and make the wrong assumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should for sure test that eris.Is
still works with this implementation
First simple test in #28 shows that it still seems to work. In the end we inherit the behaviour of errors.Join
I did not want to push into your branch, that is why I created the tiny PR @Gogomoe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry i forget to reply the comment. The eris.is and as are implemented in #27. I also added more testcases to cover the join error
@Gogomoe out of curiosity. What would you like to use value, err := someFunc(input)
if err != nil {
// wrap err and return
} When do we want to join? The only things that I can think about are
|
Another situation is retry an action for mutiple times. It's a common pattern used in our code base. I dont' want to ignore any error when all retry fails. Currently, we use errors.join in this case. You can check the use case by searching it in our code base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
t.Errorf("%v: expected { %v } got { %v }", desc, tt.wrapOutput[i]["message"], wrapMap[i]["message"]) | ||
} | ||
if _, exists := wrapMap[i]["stack"]; tt.withTrace && !exists { | ||
t.Fatalf("%v: expected a 'stack' field in the output but didn't find one { %v }", desc, errJSON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I suppose this can be t.Errorf
as we can still check the rest of the wrapError in the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the wrapMap
section from other test cases. Leet's keep it 🤪
I plan to merge this PR tomorrow. @CAJan93 Do you have more opinions about this PR? |
What's changed and what's your intention?
resolve #22
eris.Join(err...)
almost iseris.Wrap(errors.Join(err...), "join error")
Implementing and testing the format is a bit hard.
the format looks like:
Checklist
Refer to a related PR or issue link (optional)
Close #22