-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add errors package with metadata support #60
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 98.03% 98.06% +0.03%
==========================================
Files 46 47 +1
Lines 1067 1084 +17
==========================================
+ Hits 1046 1063 +17
Misses 21 21 ☔ View full report in Codecov by Sentry. |
Curious about the use-cases, can you add some description on what this solves? |
the idea is to declare generic/package level errors and then wrap them with additional context as they propagate through different layers. this allows compatibility with errors.Is while still preserving the metadata which can be used to construct detailed error messages, structured logs, detailed error responses, etc. |
i have updated the example https://github.com/gojekfarm/xtools/pull/60/files#diff-1e4aa0f94766e657148fed7d7a4aec95bd44b5bbc4c16bfbb0da3052473f7129 to show a more realistic example |
I see, like the fact that the API is quite simple. I remember @sudo-suhas created this, do give it a read, I think there are a bunch of good reads as well in root README. But I believe you are solving for a simpler use-case, I added the reference for visibility anyway. |
|
||
// Use the tags to construct detailed error messages, | ||
// log additional context, or return structured errors. | ||
fmt.Println(errTags.All()) |
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.
Add an output
block to make sure this asserts the printed value?
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 tried but the tests become flaky because of the map values are unordered
Yeah, I remember this. The internal xtools has a similar |
No description provided.