You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/05/20 18:35:54 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #6832: Make users use same representation across endpoints

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


##########
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('\'')

Review Comment:
   That changes the datatype. I'd have to switch it to use `WriteString` instead of `WriteRune` - which I can do; I don't think one is faster than the other. It just makes sense to me to use `WriteRune` when I'm writing only a single rune.



-- 
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: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org