fix : validation 메세지 정보 [속성] 추가

dev
Lim Jonguk 3 years ago
parent a4e78c5504
commit b1a7f82376

@ -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
// }
}

@ -79,16 +79,24 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
log.error("{}", validErrorMap);
log.error("##############################################################################################");
Optional<String> firstKey = validErrorMap
.keySet()
.stream()
.findFirst();
Optional<String> 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("##############################################################################################");

Loading…
Cancel
Save