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

Improve error handling #168

Closed
wneessen opened this issue Jan 23, 2024 · 1 comment · Fixed by #301
Closed

Improve error handling #168

wneessen opened this issue Jan 23, 2024 · 1 comment · Fixed by #301
Labels
enhancement New feature or request help wanted Extra attention is needed WIP Work is in progress

Comments

@wneessen
Copy link
Owner

          > Since errors are appendable

BTW, the way how code currently does "appending" is really ... bad. I think. As an author of one of (I believe) good errors packages for Go the issue with current approach is that you create a tree of joined errors. Every time you call errors.Join it creates a new error with two child errors.

A better way I think would be to have a slice of errors you append to and join just once at the end (you could even join in defer and set a named return value. errors.Join also discards all nil errors, so you could just be collecting all errors without checking (unless it influences the code flow). I did something similar here. Maybe the best way would be to extract inner loop code to sendOne internal function which returns error as usual. And then you collect errors in the loop and call final errors.Join.

Originally posted by @mitar in #166 (comment)

@wneessen
Copy link
Owner Author

wneessen commented Jan 23, 2024

Based on this comment by @mitar, this is a placeholder issue to improve the error handling, as it is - as pointed out - sub-par at the moment.

@wneessen wneessen added enhancement New feature or request help wanted Extra attention is needed TODO labels Jan 23, 2024
@wneessen wneessen added WIP Work is in progress and removed TODO labels Jun 29, 2024
@wneessen wneessen linked a pull request Sep 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed WIP Work is in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant