diff --git a/src/main/java/com/xit/core/exception/CustomBaseException.java b/src/main/java/com/xit/core/exception/CustomBaseException.java index e07d5b5..2309954 100644 --- a/src/main/java/com/xit/core/exception/CustomBaseException.java +++ b/src/main/java/com/xit/core/exception/CustomBaseException.java @@ -14,7 +14,7 @@ import java.util.ResourceBundle; @Getter @ResponseStatus(code = HttpStatus.BAD_REQUEST, reason = "Invalid parameter") public class CustomBaseException extends RuntimeException { - ResourceBundle message = ResourceBundle.getBundle("message.error"); +// ResourceBundle message = ResourceBundle.getBundle("error"); private ErrorCode errorCode; private String code; @@ -53,9 +53,9 @@ public class CustomBaseException extends RuntimeException { return super.getMessage(); } - @Override - public String getLocalizedMessage(){ - return message.getString(super.getMessage()); - //return messageSourceAccessor.get - } +// @Override +// public String getLocalizedMessage(){ +// return message.getString(super.getMessage()); +// //return messageSourceAccessor.get +// } } \ No newline at end of file diff --git a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java index c7499cf..62b99af 100644 --- a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java +++ b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java @@ -79,16 +79,24 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { log.error("{}", validErrorMap); log.error("##############################################################################################"); + Optional firstKey = validErrorMap + .keySet() + .stream() + .findFirst(); + + Optional firstMessage = validErrorMap .values() .stream() .findFirst(); + String errMsg = "["+firstKey.orElse("에러 메세지가 정의 되지 않았습니다")+"] "+firstMessage.orElse(""); + RestErrorResponse errorResponse = RestErrorResponse.builder() .status(HttpStatus.BAD_REQUEST.value()) .error(HttpStatus.BAD_REQUEST.name()) .code(HttpStatus.BAD_REQUEST.name()) - .message(firstMessage.orElse("에러 메세지가 정의 되지 않았습니다")) + .message(errMsg) .build(); log.error("##############################################################################################"); diff --git a/src/main/resources/messages/i18n/error_ko.properties b/src/main/resources/messages/i18n/error_ko.properties new file mode 100644 index 0000000..98f115c --- /dev/null +++ b/src/main/resources/messages/i18n/error_ko.properties @@ -0,0 +1 @@ +AAA=\uD55C\uAE00\uC5D0\uB7EC \ No newline at end of file diff --git a/src/main/resources/messages/i18n/error_ko_KR.properties b/src/main/resources/messages/i18n/error_ko_KR.properties new file mode 100644 index 0000000..98f115c --- /dev/null +++ b/src/main/resources/messages/i18n/error_ko_KR.properties @@ -0,0 +1 @@ +AAA=\uD55C\uAE00\uC5D0\uB7EC \ No newline at end of file