Skip to content

Improve error handling #168

@wneessen

Description

@wneessen
          > 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    WIPWork is in progressenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions