Skip to content
Snippets Groups Projects
Commit 5e8ff6ac authored by Michal Badin's avatar Michal Badin
Browse files

refactoring(ApplicationService): Changed exception handling

parent d18292e9
No related branches found
No related tags found
3 merge requests!54Merge develop into main,!48Scenario,!44Security
Pipeline #
......@@ -8,11 +8,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientException;
import java.time.LocalDate;
import java.util.HashMap;
......@@ -53,7 +55,7 @@ public class ApplicationService {
try {
sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_NEW, List.of(savedApplication.getEmail()));
} catch (RestClientException | IllegalArgumentException e) {
} catch (WebClientException e) {
log.debug(String.format("The notification module is not reachable on the URL: %s, exception %s", NOTIFICATION_MODULE_URL + NOTIFICATION_MODULE_URI_NEW, e));
}
......@@ -80,7 +82,7 @@ public class ApplicationService {
if (savedApplication.getStatus() != ApplicationStatusEnum.PENDING) {
try {
sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_STATUS, NOTIFICATION_RECEIVERS);
} catch (RestClientException | IllegalArgumentException e) {
} catch (WebClientException e) {
log.debug(String.format("The notification module is not reachable on the URL: %s, exception %s", NOTIFICATION_MODULE_URL + NOTIFICATION_MODULE_URI_STATUS, e));
}
}
......@@ -98,10 +100,7 @@ public class ApplicationService {
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(notification)
.retrieve()
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})
.doOnError(error -> {
throw new RestClientException("Failed to send POST request", error);
})
.bodyToMono(Resource.class)
.block();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment