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

Add errors package with metadata support #60

Merged
merged 3 commits into from
Jan 2, 2025
Merged

Add errors package with metadata support #60

merged 3 commits into from
Jan 2, 2025

Conversation

sonnes
Copy link
Collaborator

@sonnes sonnes commented Nov 29, 2024

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.06%. Comparing base (599750f) to head (f69e79a).

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.
📢 Have feedback on the report? Share it here.

@ajatprabha
Copy link
Contributor

Curious about the use-cases, can you add some description on what this solves?

@sonnes
Copy link
Collaborator Author

sonnes commented Dec 19, 2024

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.

@sonnes
Copy link
Collaborator Author

sonnes commented Dec 19, 2024

@ajatprabha
Copy link
Contributor

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())
Copy link
Contributor

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?

Copy link
Collaborator Author

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

@sonnes
Copy link
Collaborator Author

sonnes commented Dec 19, 2024

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.

Yeah, I remember this. The internal xtools has a similar Code based API.

@sonnes sonnes merged commit 8ef71dc into main Jan 2, 2025
5 checks passed
@sonnes sonnes deleted the errors branch January 2, 2025 06:48
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.

3 participants