-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refoctor: category advice contoller 설정
- Loading branch information
Showing
1 changed file
with
6 additions
and
4 deletions.
There are no files selected for viewing
10 changes: 6 additions & 4 deletions
10
module-api/src/main/java/com/yapp/sharefood/category/advice/CategoryAdviceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package com.yapp.sharefood.category.advice; | ||
|
||
import com.yapp.sharefood.category.exception.CategoryNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
import com.yapp.sharefood.common.error.ErrorResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
@RequiredArgsConstructor | ||
@Order(Ordered.HIGHEST_PRECEDENCE) | ||
public class CategoryAdviceController { | ||
@ExceptionHandler(CategoryNotFoundException.class) | ||
protected ResponseEntity<String> handlerCategoryNotFoundException(final CategoryNotFoundException exception) { | ||
protected ResponseEntity<ErrorResponse> handlerCategoryNotFoundException(final CategoryNotFoundException exception) { | ||
log.info("CategoryNotFoundException: {}", exception.getMessage(), exception); | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getMessage()); | ||
return ErrorResponse.toResponseEntity(HttpStatus.NOT_FOUND, exception.getMessage()); | ||
} | ||
} |