-
Notifications
You must be signed in to change notification settings - Fork 116
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
Replace the multierror dependency with a simple error aggregator. #207
Conversation
} | ||
} | ||
tf.files = nil | ||
return nil |
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.
pretty sure this was a bug 😅
701c271
to
f4fc3bc
Compare
estargz/errors.go
Outdated
limitations under the License. | ||
*/ | ||
|
||
package estargz |
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 feel this should be a new subpackage like estargz/errorutil
.
@ktock WDYT?
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.
Yes, let's separate this to another package.
@mattmoor
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.
done
estargz/build.go
Outdated
} | ||
} | ||
tf.files = nil | ||
return nil | ||
return allErr |
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.
We should return nil when no error is appended to allErr?
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.
if nothing is ever appended to it, it is still nil
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.
🤔 or you are saying this is the weird Go typed nil nonsense. blah, let me see...
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 reworked this ~completely to just use []error
directly and have the errorutil package expose an Aggregate
method for combining them. I think this ends up being a lot simpler, and it avoid the typed nil case.
a10ff77
to
5b24ccd
Compare
estargz/errorutil/errors.go
Outdated
return strings.Join(points, "\n\t") | ||
} | ||
|
||
var _ error = (*Errors)(nil) |
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.
We have tests, so we do not need this line
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 reworked the change pretty dramatically, so I'm no longer implementing a custom error type at all anyways.
Please squash commits |
This lets functions that want to aggregate and return a collection of errors use a `[]error` to accumulate them, and `errorutil.Aggregate(list)` to turn them into a single `error`. If the list is empty, the `error` will be nil. If the list is a singleton, it will return the single error. Otherwise, it will construct a new error combining the constituent error messages. Fixes: containerd#205 Signed-off-by: Matt Moore <mattmoor@vmware.com>
5b24ccd
to
cf6d7a0
Compare
Given the overhaul I just gave this, I didn't even bother with a squash, since it's a completely different change. I'll update the PR subject and description above now to reflect the new commit message. |
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 on green.
Thanks for the quick review, and thanks again for driving this super important work! 🤩 |
This lets functions that want to aggregate and return a collection of errors use a
[]error
to accumulate them, anderrorutil.Aggregate(list)
to turn them into a singleerror
. If the list is empty, theerror
will be nil. If the list is a singleton, it will return the single error. Otherwise, it will construct a new error combining the constituent error messages.Fixes: #205