Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/ewrap/error_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ func (eg *ErrorGroup) Error() string {
}
}

// ErrorOrNil returns the ErrorGroup itself if it contains errors, or nil if empty.
func (eg *ErrorGroup) ErrorOrNil() error {
if eg.HasErrors() {
return eg
}

return nil
}

// Errors returns a copy of all errors in the group.
func (eg *ErrorGroup) Errors() []error {
eg.mu.RLock()
Expand Down