diff --git a/src/main/java/org/folio/linked/data/exception/RequestProcessingExceptionBuilder.java b/src/main/java/org/folio/linked/data/exception/RequestProcessingExceptionBuilder.java index 44a1b583..15d6510c 100644 --- a/src/main/java/org/folio/linked/data/exception/RequestProcessingExceptionBuilder.java +++ b/src/main/java/org/folio/linked/data/exception/RequestProcessingExceptionBuilder.java @@ -49,8 +49,8 @@ public RequestProcessingException notFoundSourceRecordException(String idType, S return requestProcessingException(notFoundError, "Source Record", idType, idValue, "Source Record storage"); } - public RequestProcessingException failedDependencyException(String message, Throwable t) { - return requestProcessingException(errorResponseConfig.getFailedDependency(), message, t.getMessage()); + public RequestProcessingException failedDependencyException(String message, String reason) { + return requestProcessingException(errorResponseConfig.getFailedDependency(), message, reason); } private RequestProcessingException requestProcessingException(ErrorResponseConfig.Error error, String... arguments) { diff --git a/src/main/java/org/folio/linked/data/service/search/InstanceSearchServiceImpl.java b/src/main/java/org/folio/linked/data/service/search/InstanceSearchServiceImpl.java index b2be312a..18253e19 100644 --- a/src/main/java/org/folio/linked/data/service/search/InstanceSearchServiceImpl.java +++ b/src/main/java/org/folio/linked/data/service/search/InstanceSearchServiceImpl.java @@ -9,7 +9,6 @@ import lombok.RequiredArgsConstructor; import org.folio.linked.data.client.SearchClient; import org.folio.linked.data.domain.dto.SearchResponseTotalOnly; -import org.folio.linked.data.exception.SearchException; import org.springframework.stereotype.Service; @Service @@ -36,11 +35,7 @@ public SearchResponseTotalOnly searchByLccnExcludingId(Collection lccn, } private SearchResponseTotalOnly search(String query) { - try { - return searchClient.searchInstances(query).getBody(); - } catch (Exception e) { - throw new SearchException("Unable to reach search service", e); - } + return searchClient.searchInstances(query).getBody(); } private String getLccnQuery(Collection lccnCol) { diff --git a/src/main/java/org/folio/linked/data/validation/dto/LccnUniquenessValidator.java b/src/main/java/org/folio/linked/data/validation/dto/LccnUniquenessValidator.java index 41e960f3..66792870 100644 --- a/src/main/java/org/folio/linked/data/validation/dto/LccnUniquenessValidator.java +++ b/src/main/java/org/folio/linked/data/validation/dto/LccnUniquenessValidator.java @@ -58,7 +58,8 @@ private SearchResponseTotalOnly findInstanceWithLccn(List lccn, String i return instanceSearchService.searchByLccnExcludingId(lccn, inventoryId); } catch (Exception e) { log.error(e); - throw exceptionBuilder.failedDependencyException("Could not validate LCCN for duplicate", e); + throw exceptionBuilder.failedDependencyException( + "Could not validate LCCN for duplicate", "Unable to reach search service"); } } diff --git a/src/test/java/org/folio/linked/data/service/search/InstanceSearchServiceImplTest.java b/src/test/java/org/folio/linked/data/service/search/InstanceSearchServiceImplTest.java index 11ebff45..aa5eb3fd 100644 --- a/src/test/java/org/folio/linked/data/service/search/InstanceSearchServiceImplTest.java +++ b/src/test/java/org/folio/linked/data/service/search/InstanceSearchServiceImplTest.java @@ -11,7 +11,6 @@ import java.util.stream.Stream; import org.folio.linked.data.client.SearchClient; import org.folio.linked.data.domain.dto.SearchResponseTotalOnly; -import org.folio.linked.data.exception.SearchException; import org.folio.spring.testing.type.UnitTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -45,7 +44,7 @@ void shouldReturnZeroTotalRecords_ifSearchClientThrowsNotFound() { var lccn = List.of(""); // expect - assertThrows(SearchException.class, () -> searchService.searchByLccn(lccn)); + assertThrows(FeignException.NotFound.class, () -> searchService.searchByLccn(lccn)); } @Test