Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d24f5e4

Browse files
committed
Use NotFoundException in service methods.
1 parent 91b177a commit d24f5e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎src/main/java/com/nihat/springwebfluxdemo/services/ProductServiceImpl.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.nihat.springwebfluxdemo.services;
22

3+
import com.nihat.springwebfluxdemo.exception.NotFoundException;
34
import com.nihat.springwebfluxdemo.mappers.ProductMapper;
45
import com.nihat.springwebfluxdemo.model.ProductDTO;
56
import 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /