shamrickus commented on code in PR #6832:
URL: https://github.com/apache/trafficcontrol/pull/6832#discussion_r878455062


##########
lib/go-tc/tovalidate/validate.go:
##########
@@ -43,3 +45,28 @@ func ToErrors(err map[string]error) []error {
        }
        return vErrors
 }
+
+// ToError converts a map of strings to errors into a single error.
+//
+// Because multiple errors are collapsed, errors cannot be wrapped and 
therefore
+// error identity cannot be preserved.
+func ToError(err map[string]error) error {
+       if len(err) == 0 {
+               return nil
+       }
+       var b strings.Builder
+       for key, value := range err {
+               if value != nil {
+                       b.WriteRune('\'')
+                       b.WriteString(key)
+                       b.WriteString("' ")
+                       b.WriteString(value.Error())
+                       b.WriteString(", ")
+               }
+       }
+       msg := strings.TrimSuffix(b.String(), ", ")
+       if msg == "" {
+               return nil
+       }
+       return errors.New(strings.TrimSuffix(b.String(), ", "))

Review Comment:
   How would that be possible, they're the same statement aside from the error 
wrapping?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to