diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java index 9594ca32f1..784fcf2812 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java @@ -1,7 +1,7 @@ package com.baeldung.webclient.status; -import com.baeldung.webclient.status.exception.BadRequestException; -import com.baeldung.webclient.status.exception.ServerErrorException; +import com.baeldung.webclient.status.exception.CustomBadRequestException; +import com.baeldung.webclient.status.exception.CustomServerErrorException; import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.ExchangeFilterFunction; @@ -32,10 +32,10 @@ public class WebClientStatusCodeHandler { .retrieve() .onStatus( HttpStatus.INTERNAL_SERVER_ERROR::equals, - response -> response.bodyToMono(String.class).map(ServerErrorException::new)) + response -> response.bodyToMono(String.class).map(CustomServerErrorException::new)) .onStatus( HttpStatus.BAD_REQUEST::equals, - response -> response.bodyToMono(String.class).map(BadRequestException::new)) + response -> response.bodyToMono(String.class).map(CustomBadRequestException::new)) .bodyToMono(String.class); } @@ -43,11 +43,11 @@ public class WebClientStatusCodeHandler { HttpStatus status = response.statusCode(); if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) { return response.bodyToMono(String.class) - .flatMap(body -> Mono.error(new ServerErrorException(body))); + .flatMap(body -> Mono.error(new CustomServerErrorException(body))); } if (HttpStatus.BAD_REQUEST.equals(status)) { return response.bodyToMono(String.class) - .flatMap(body -> Mono.error(new BadRequestException(body))); + .flatMap(body -> Mono.error(new CustomBadRequestException(body))); } return Mono.just(response); } diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java deleted file mode 100644 index bf5c599805..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/BadRequestException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.webclient.status.exception; - -public class BadRequestException extends Exception { - public BadRequestException(String message) { - super(message); - } -} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java new file mode 100644 index 0000000000..ddc814b2d4 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java @@ -0,0 +1,7 @@ +package com.baeldung.webclient.status.exception; + +public class CustomBadRequestException extends Exception { + public CustomBadRequestException(String message) { + super(message); + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java new file mode 100644 index 0000000000..12adbc94e4 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java @@ -0,0 +1,7 @@ +package com.baeldung.webclient.status.exception; + +public class CustomServerErrorException extends Exception { + public CustomServerErrorException(String message) { + super(message); + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java deleted file mode 100644 index 7e97f17dff..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/ServerErrorException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.webclient.status.exception; - -public class ServerErrorException extends Exception { - public ServerErrorException(String message) { - super(message); - } -}