From 59f565dc3031b170b9f4f4ac0dba6ef4257f2f4b Mon Sep 17 00:00:00 2001 From: shinmj Date: Thu, 18 Nov 2021 16:17:05 +0900 Subject: [PATCH] =?UTF-8?q?=20=EB=B3=B4=EC=95=88=EC=A0=90=EA=B2=80=20?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=88=98=EC=A0=95(module-common)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/module-common/build.gradle | 1 + .../cloud/common/exception/dto/ErrorResponse.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/module-common/build.gradle b/backend/module-common/build.gradle index 10cc97d..68a7ac2 100644 --- a/backend/module-common/build.gradle +++ b/backend/module-common/build.gradle @@ -4,6 +4,7 @@ plugins { // querydsl id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10' id 'java' + id "org.sonarqube" version "2.7" } group 'org.egovframe.cloud' diff --git a/backend/module-common/src/main/java/org/egovframe/cloud/common/exception/dto/ErrorResponse.java b/backend/module-common/src/main/java/org/egovframe/cloud/common/exception/dto/ErrorResponse.java index d058f2a..ed665c6 100644 --- a/backend/module-common/src/main/java/org/egovframe/cloud/common/exception/dto/ErrorResponse.java +++ b/backend/module-common/src/main/java/org/egovframe/cloud/common/exception/dto/ErrorResponse.java @@ -48,7 +48,7 @@ public class ErrorResponse { this.message = messageSource.getMessage(code.getMessage(), new Object[]{}, DEFAULT_ERROR_MESSAGE, LocaleContextHolder.getLocale()); this.status = code.getStatus(); this.code = code.getCode(); - this.errors = errors; + this.errors = new ArrayList<>(errors); } private ErrorResponse(final ErrorCode code, MessageSource messageSource) { @@ -125,8 +125,12 @@ public class ErrorResponse { * @return */ public static ErrorResponse of(MethodArgumentTypeMismatchException e, MessageSource messageSource) { - final String value = e.getValue() == null ? "" : e.getValue().toString(); - final List errors = ErrorResponse.FieldError.of(e.getName(), value, e.getErrorCode()); + if (e.getValue() == null) { + return new ErrorResponse(ErrorCode.INVALID_TYPE_VALUE, ErrorResponse.FieldError.of(e.getName(), "", e.getErrorCode()), messageSource); + } + + final List errors = + ErrorResponse.FieldError.of(e.getName(), String.valueOf(e.getValue()), e.getErrorCode()); return new ErrorResponse(ErrorCode.INVALID_TYPE_VALUE, errors, messageSource); }