Skip to content

Commit 66582e2

Browse files
committed
removing comments which don't add value
1 parent 718302b commit 66582e2

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

response/error.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ func parseJSONResponse(bodyBytes []byte, apiError *APIError) {
8989

9090
// parseXMLResponse dynamically parses XML error responses and accumulates potential error messages.
9191
func parseXMLResponse(bodyBytes []byte, apiError *APIError) {
92-
// Always set the Raw field to the entire XML content for debugging purposes.
9392
apiError.RawResponse = string(bodyBytes)
9493

95-
// Parse the XML document.
9694
doc, err := xmlquery.Parse(bytes.NewReader(bodyBytes))
9795
if err != nil {
9896
return
@@ -111,7 +109,6 @@ func parseXMLResponse(bodyBytes []byte, apiError *APIError) {
111109

112110
traverse(doc)
113111

114-
// Concatenate all messages found in the XML for the 'Message' field of APIError.
115112
if len(messages) > 0 {
116113
apiError.Message = strings.Join(messages, "; ")
117114
} else {
@@ -122,29 +119,23 @@ func parseXMLResponse(bodyBytes []byte, apiError *APIError) {
122119

123120
// parseTextResponse updates the APIError structure based on a plain text error response and logs it.
124121
func parseTextResponse(bodyBytes []byte, apiError *APIError) {
125-
// Convert the body bytes to a string and assign it to both the message and RawResponse fields of APIError.
126122
bodyText := string(bodyBytes)
127123
apiError.RawResponse = bodyText
128-
129-
// Directly use the body text as the error message if the Message field is empty.
130124
apiError.Message = bodyText
131-
132125
}
133126

134127
// parseHTMLResponse extracts meaningful information from an HTML error response,
135128
// concatenating all text within <p> tags and links found within them.
136129
func parseHTMLResponse(bodyBytes []byte, apiError *APIError) {
137-
// Set the entire HTML content as the RawResponse for debugging purposes.
138130
apiError.RawResponse = string(bodyBytes)
139131

140-
// Parse the HTML document.
141132
reader := bytes.NewReader(bodyBytes)
142133
doc, err := html.Parse(reader)
143134
if err != nil {
144135
return
145136
}
146137

147-
var messages []string // To accumulate messages and links.
138+
var messages []string
148139
var parse func(*html.Node)
149140
parse = func(n *html.Node) {
150141
if n.Type == html.ElementNode && n.Data == "p" {

0 commit comments

Comments
 (0)