Skip to content

Commit 6d2c8b8

Browse files
authored
Switch to errors.Join (#54)
1 parent 1451f5d commit 6d2c8b8

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

decode.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ func (o UnmarshalOptions) unmarshalNode(node *yaml.Node, message proto.Message,
178178
}
179179
}
180180

181-
if len(unm.errors) > 0 {
182-
return unmarshalErrors(unm.errors)
183-
}
184-
return nil
181+
return errors.Join(unm.errors...)
185182
}
186183

187184
const atTypeFieldName = "@type"

errors.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,3 @@ type violationError struct {
5858
func (v *violationError) Error() string {
5959
return protovalidate.FieldPathString(v.Violation.GetField()) + ": " + v.Violation.GetMessage() + " (" + v.Violation.GetConstraintId() + ")"
6060
}
61-
62-
// TODO: Use errors.Join instead, once we drop support for Go <1.21.
63-
type unmarshalErrors []error
64-
65-
func (ue unmarshalErrors) Error() string {
66-
errorStrings := make([]string, len(ue))
67-
for i, err := range ue {
68-
errorStrings[i] = err.Error()
69-
}
70-
return strings.Join(errorStrings, "\n")
71-
}
72-
73-
func (ue unmarshalErrors) Unwrap() []error {
74-
return ue
75-
}

0 commit comments

Comments
 (0)