Files
FLOWER/src/main/java/com/krt/flower/Flower/exception/ApiExceptionAdvice.java
2025-12-09 11:54:11 +09:00

34 lines
1.2 KiB
Java

package com.krt.flower.Flower.exception;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class ApiExceptionAdvice {
@ExceptionHandler({ApiException.class})
public ResponseEntity<ApiExceptionEntity> exceptionHandler(ApiException apiEx) {
return ResponseEntity
.status(apiEx.exceptionDto.getStatus())
.body(ApiExceptionEntity.builder()
.errorCode(apiEx.exceptionDto.getCode())
.errorMessage(apiEx.exceptionDto.getMessage())
.errorPoint(apiEx.exceptionDto.getErrorPoint())
.build());
}
@ExceptionHandler({TextException.class})
public ResponseEntity<TextExceptionEntity> exceptionHandler(TextException apiEx) {
return ResponseEntity
.status(apiEx.exceptionDto.getStatus())
.body(TextExceptionEntity.builder()
.errorCode(apiEx.exceptionDto.getCode())
.errorMessage(apiEx.exceptionDto.getMessage())
.build());
}
}