Add utility function to errors to allow format composition

This commit is contained in:
Joe Betz
2025-09-16 17:57:59 -04:00
parent f24a967c42
commit 697113f5f0

View File

@@ -341,6 +341,14 @@ func (list ErrorList) MarkCoveredByDeclarative() ErrorList {
return list
}
// PrefixDetail adds a prefix to the Detail for all errors in the list and returns the updated list.
func (list ErrorList) PrefixDetail(prefix string) ErrorList {
for _, err := range list {
err.Detail = prefix + err.Detail
}
return list
}
// ToAggregate converts the ErrorList into an errors.Aggregate.
func (list ErrorList) ToAggregate() utilerrors.Aggregate {
if len(list) == 0 {