From 24d4b57b7e289bab17998416cd3cdf5ce975eef8 Mon Sep 17 00:00:00 2001 From: Gavin Cook Date: Wed, 10 Apr 2024 16:08:00 +0100 Subject: [PATCH] Improving logging II --- .../gap/adminbackend/services/OpenSearchService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/OpenSearchService.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/OpenSearchService.java index 868d12c9..ff057081 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/OpenSearchService.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/OpenSearchService.java @@ -38,7 +38,9 @@ public void indexEntry(final CMAEntry contentfulEntry) { .onStatus(HttpStatus::isError, clientResponse -> { log.info("Elastic search update json string: {}", body); log.error("response code from open search: {}", clientResponse.statusCode()); - log.error("response from open search: {}", clientResponse.bodyToMono(String.class)); + log.error("response headers from open search: {}", clientResponse.headers().asHttpHeaders()); + log.error("response body from open search: {}", clientResponse.bodyToMono(String.class)); + throw new IndexingException("failed to add CMA entry with ID " + contentfulEntry.getId() + " to index"); }) .bodyToMono(void.class) @@ -56,7 +58,9 @@ public void removeIndexEntry(final CMAEntry contentfulEntry) { .onStatus(HttpStatus::isError, clientResponse -> { log.info("Elastic search delete json string: {}", body); log.error("response code from open search: {}", clientResponse.statusCode()); - log.error("response from open search: {}", clientResponse.bodyToMono(String.class)); + log.error("response headers from open search: {}", clientResponse.headers().asHttpHeaders()); + log.error("response body from open search: {}", clientResponse.bodyToMono(String.class)); + throw new IndexingException("failed to remove CMA entry with ID " + contentfulEntry.getId() + " from index"); }) .bodyToMono(void.class)