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 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 exceptionHandler(TextException apiEx) { return ResponseEntity .status(apiEx.exceptionDto.getStatus()) .body(TextExceptionEntity.builder() .errorCode(apiEx.exceptionDto.getCode()) .errorMessage(apiEx.exceptionDto.getMessage()) .build()); } }