11package com .nihat .springwebfluxdemo .services ;
22
3+ import com .nihat .springwebfluxdemo .exception .NotFoundException ;
34import com .nihat .springwebfluxdemo .mappers .ProductMapper ;
45import com .nihat .springwebfluxdemo .model .ProductDTO ;
56import com .nihat .springwebfluxdemo .repositories .ProductRepository ;
@@ -24,7 +25,7 @@ public Flux<ProductDTO> getAllProducts() {
2425 @ Override
2526 public Mono <ProductDTO > getProductById (String id ) {
2627 return productRepository .findById (id )
27- .switchIfEmpty (Mono .error (new RuntimeException ("Not found" )))
28+ .switchIfEmpty (Mono .error (new NotFoundException ("Not found" )))
2829 .map (productMapper ::toProductDTO );
2930 }
3031
@@ -38,7 +39,7 @@ public Mono<ProductDTO> saveProduct(Mono<ProductDTO> productDTO) {
3839 @ Override
3940 public Mono <ProductDTO > updateProduct (String id , ProductDTO productDTO ) {
4041 return productRepository .findById (id )
41- .switchIfEmpty (Mono .error (new RuntimeException ("Not found" )))
42+ .switchIfEmpty (Mono .error (new NotFoundException ("Not found" )))
4243 .map (found -> {
4344 found .setName (productDTO .getName ());
4445 found .setDescription (productDTO .getDescription ());
0 commit comments