kwin commented on code in PR #2326:
URL: https://github.com/apache/maven-resolver/pull/2326#discussion_r4603236430


##########
maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/http/RFC9457/RFC9457Reporter.java:
##########
@@ -133,12 +167,42 @@ public void generateException(T response, 
BiConsumerChecked<Integer, String, E>
                 }
                 if (rfc9457Payload != null) {
                     throw new HttpRFC9457Exception(statusCode, reasonPhrase, 
rfc9457Payload);
+                } else {
+                    throw new HttpTransporterException(
+                            statusCode, reasonPhrase, 
generateBodyExtract(body, contentType));
                 }
-                baseException.accept(statusCode, reasonPhrase);
-                return;
+            } else {
+                // No body found but it is representing a RFC 9457 message due 
to the content type.
+                throw new HttpRFC9457Exception(statusCode, reasonPhrase, 
RFC9457Payload.INSTANCE);
+            }
+        } else {
+            try {
+                body = getBody(response);
+                throw new HttpTransporterException(statusCode, reasonPhrase, 
generateBodyExtract(body, contentType));
+            } catch (IOException e) {
+                throw new HttpTransporterException(statusCode, reasonPhrase);
             }
-            throw new HttpRFC9457Exception(statusCode, reasonPhrase, 
RFC9457Payload.INSTANCE);
         }
-        baseException.accept(statusCode, reasonPhrase);
+    }
+
+    /**
+     * Generates a body extract from the given body string (usually HTML)
+     * This method can be overridden to provide custom logic for generating a 
body extract.
+     *
+     * @param body The body string to generate the extract from (already 
truncated to {@link #MAX_BODY_BYTES} bytes).
+     * @param contentType The content type of the body, may be {@code null} if 
unknown.
+     * @return The generated body extract.
+     */
+    public static String generateBodyExtract(String body, String contentType) {
+        if (contentType != null && contentType.startsWith("text/html")) {
+            // convert from HTML to plain text
+

Review Comment:
   Should we use 
[JSoup](https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/examples/HtmlToPlainText.java)
 to convert or leave it as HTML?



-- 
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