You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sj...@apache.org on 2026/08/29 08:10:28 UTC

(tooling-atr-maven-plugin) branch main updated: Enhance AtrClientException to include HTTP method and URL

This is an automated email from the ASF dual-hosted git repository.

slawekjaranowski pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-atr-maven-plugin.git


The following commit(s) were added to refs/heads/main by this push:
     new 01a87fe  Enhance AtrClientException to include HTTP method and URL
01a87fe is described below

commit 01a87fe0c19710d547f6135402e6d86357ad4c99
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Fri Aug 28 22:35:15 2026 +0200

    Enhance AtrClientException to include HTTP method and URL
    
    What changed:
    - Modified constructor of `AtrClientException` to accept HTTP method and URL.
    - Updated exception throwing in `AtrClientImpl` to include method and URL details.
    
    Why:
    - Provides more context in error messages for better debugging.
    - Improves traceability of requests leading to exceptions.
---
 src/main/java/org/apache/tooling/atr/client/AtrClientException.java | 6 ++++--
 src/main/java/org/apache/tooling/atr/client/AtrClientImpl.java      | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/tooling/atr/client/AtrClientException.java b/src/main/java/org/apache/tooling/atr/client/AtrClientException.java
index 4cfe9a9..82d2454 100644
--- a/src/main/java/org/apache/tooling/atr/client/AtrClientException.java
+++ b/src/main/java/org/apache/tooling/atr/client/AtrClientException.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tooling.atr.client;
 
+import java.net.URL;
+
 /**
  * Exception thrown by the ATR client.
  */
@@ -35,8 +37,8 @@ public class AtrClientException extends Exception {
         this.responseCode = -1;
     }
 
-    public AtrClientException(int responseCode, String errorResponse) {
-        super("ATR client error: HTTP " + responseCode + ": " + errorResponse);
+    AtrClientException(int responseCode, String errorResponse, String method, URL url) {
+        super("ATR client error: " + method + " " + url + " HTTP " + responseCode + ": " + errorResponse);
         this.responseCode = responseCode;
     }
 
diff --git a/src/main/java/org/apache/tooling/atr/client/AtrClientImpl.java b/src/main/java/org/apache/tooling/atr/client/AtrClientImpl.java
index f653d52..87abb85 100644
--- a/src/main/java/org/apache/tooling/atr/client/AtrClientImpl.java
+++ b/src/main/java/org/apache/tooling/atr/client/AtrClientImpl.java
@@ -181,7 +181,7 @@ class AtrClientImpl implements AtrClient {
             return objectMapper.readValue(conn.getInputStream(), responseClass);
         } else {
             String errorResponse = readErrorResponse(conn.getErrorStream());
-            throw new AtrClientException(responseCode, errorResponse);
+            throw new AtrClientException(responseCode, errorResponse, "GET", uploadUrl);
         }
     }
 
@@ -211,7 +211,7 @@ class AtrClientImpl implements AtrClient {
             return objectMapper.readValue(conn.getInputStream(), responseClass);
         } else {
             String errorResponse = readErrorResponse(conn.getErrorStream());
-            throw new AtrClientException(responseCode, errorResponse);
+            throw new AtrClientException(responseCode, errorResponse, "POST", uploadUrl);
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org