summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2024-05-16 15:55:09 +0200
committerjonmv <venstad@gmail.com>2024-05-16 15:55:09 +0200
commita2c23bb2ecd78118c1282944cb3c30076b47775c (patch)
tree92f4bc2b7f0531dbce373d639785967a8cab547a
parent2b1ba7831859c0c4caaa487fd2fb6d6f49b5a7d4 (diff)
Prepend doc-id when known, in FeedException.getMessage()
-rw-r--r--vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedException.java5
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java4
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpRequestStrategyTest.java6
3 files changed, 10 insertions, 5 deletions
diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedException.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedException.java
index 74f906149b2..dd1327f7ccf 100644
--- a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedException.java
+++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedException.java
@@ -44,4 +44,9 @@ public class FeedException extends RuntimeException {
public Optional<DocumentId> documentId() { return Optional.ofNullable(documentId); }
+ @Override
+ public String getMessage() {
+ return documentId != null ? "(" + documentId + ") " + super.getMessage() : super.getMessage();
+ }
+
}
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
index 28bde16f457..57dffc5a668 100644
--- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
@@ -174,7 +174,7 @@ class HttpFeedClientTest {
.timeout(Duration.ofSeconds(5)))
.get());
assertTrue(expected.getCause() instanceof ResultException);
- assertEquals("Ooops! ... I did it again.", expected.getCause().getMessage());
+ assertEquals("(id:ns:type::0) Ooops! ... I did it again.", expected.getCause().getMessage());
assertEquals("[ { \"message\": \"I played with your heart. Got lost in the game.\" } ]", ((ResultException) expected.getCause()).getTrace().get());
@@ -207,7 +207,7 @@ class HttpFeedClientTest {
"json",
OperationParameters.empty())
.get());
- assertEquals("Status 500 executing 'POST /document/v1/ns/type/docid/0': Alla ska i jorden.", expected.getCause().getMessage());
+ assertEquals("(id:ns:type::0) Status 500 executing 'POST /document/v1/ns/type/docid/0': Alla ska i jorden.", expected.getCause().getMessage());
}
@Test
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpRequestStrategyTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpRequestStrategyTest.java
index 853d7904f63..74288de6dee 100644
--- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpRequestStrategyTest.java
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpRequestStrategyTest.java
@@ -112,7 +112,7 @@ class HttpRequestStrategyTest {
ExecutionException expected = assertThrows(ExecutionException.class,
() -> strategy.enqueue(id1, request).get());
assertInstanceOf(FeedException.class, expected.getCause());
- assertEquals("java.lang.RuntimeException: boom", expected.getCause().getMessage());
+ assertEquals("(id:ns:type::1) java.lang.RuntimeException: boom", expected.getCause().getMessage());
assertEquals(1, strategy.stats().requests());
// IOException is retried.
@@ -266,7 +266,7 @@ class HttpRequestStrategyTest {
CompletableFuture<HttpResponse> delayed = strategy.enqueue(id5, request);
phaser.arriveAndAwaitAdvance(); // retried is allowed to dispatch, and will be retried async.
// failed immediately fails, and lets us assert the above retry is indeed enqueued.
- assertEquals("ai.vespa.feed.client.FeedException: java.lang.RuntimeException: fatal",
+ assertEquals("ai.vespa.feed.client.FeedException: (id:ns:type::3) java.lang.RuntimeException: fatal",
assertThrows(ExecutionException.class, failed::get).getMessage());
phaser.arriveAndAwaitAdvance(); // blocked starts dispatch, and hangs, blocking dispatch thread.
@@ -293,7 +293,7 @@ class HttpRequestStrategyTest {
assertThrows(ExecutionException.class, blocked::get).getMessage());
assertEquals("ai.vespa.feed.client.FeedException: Operation aborted",
assertThrows(ExecutionException.class, delayed::get).getMessage());
- assertEquals("ai.vespa.feed.client.FeedException: java.io.IOException: failed",
+ assertEquals("ai.vespa.feed.client.FeedException: (id:ns:type::2) java.io.IOException: failed",
assertThrows(ExecutionException.class, retried::get).getMessage());
assertEquals("ai.vespa.feed.client.FeedException: Operation aborted",
assertThrows(ExecutionException.class, strategy.enqueue(id1, request)::get).getMessage());