feat: api wrapping
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.kamco.cd.kamcoback.config;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@Slf4j
|
||||
@Order(value = 1)
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
// 로그인 정보가 잘못됐습니다 권한 없음
|
||||
@org.springframework.web.bind.annotation.ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(EntityNotFoundException.class)
|
||||
public ApiResponseDto<String> handlerEntityNotFoundException(EntityNotFoundException e) {
|
||||
log.warn("[EntityNotFoundException] resource :{} ", e.getMessage());
|
||||
String message = String.format("%s [%s]", e.getMessage(), e.getCause());
|
||||
return ApiResponseDto.createException(ApiResponseDto.ApiResponseCode.NOT_FOUND, message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user