diff --git a/src/main/java/kr/xit/framework/support/exception/resolver/AjaxExceptionViewResolver.java b/src/main/java/kr/xit/framework/support/exception/resolver/AjaxExceptionViewResolver.java index 0e6bac64..4eebf7f8 100644 --- a/src/main/java/kr/xit/framework/support/exception/resolver/AjaxExceptionViewResolver.java +++ b/src/main/java/kr/xit/framework/support/exception/resolver/AjaxExceptionViewResolver.java @@ -2,11 +2,13 @@ package kr.xit.framework.support.exception.resolver; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.sql.SQLIntegrityConstraintViolationException; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.ModelAndView; @@ -36,11 +38,24 @@ public class AjaxExceptionViewResolver extends AbstractExceptionViewResolver { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream pinrtStream = new PrintStream(out); - exception.printStackTrace(pinrtStream); - String stackTraceString = ""; - if(Globals.IS_SP_ALERT_MSG) stackTraceString = out.toString(); Map tempMap = AjaxMessageMapRenderer.error(errorCode, errorArguments); + String stackTraceString = ""; + tempMap.put("result", false); + exception.printStackTrace(pinrtStream); + if(Globals.IS_SP_ALERT_MSG) stackTraceString = out.toString(); + + // Duplicate exception + if(exception instanceof SQLIntegrityConstraintViolationException + || exception instanceof DataIntegrityViolationException){ + tempMap.put("message", "요청 처리에 실패하였습니다[이미 등록된 데이타 요청]"); + }else{ + if(Globals.IS_SP_ALERT_MSG){ + exception.printStackTrace(pinrtStream); + stackTraceString = out.toString(); + } + } + if(Globals.IS_SP_ALERT_MSG) tempMap.put("message", tempMap.get("message")+"\n"+stackTraceString); else tempMap.put("message", tempMap.get("message")); return new ModelAndView(getView(), tempMap); diff --git a/src/main/java/kr/xit/framework/support/exception/resolver/NormalExceptionViewResolver.java b/src/main/java/kr/xit/framework/support/exception/resolver/NormalExceptionViewResolver.java index 4dd1afff..a5e916a4 100644 --- a/src/main/java/kr/xit/framework/support/exception/resolver/NormalExceptionViewResolver.java +++ b/src/main/java/kr/xit/framework/support/exception/resolver/NormalExceptionViewResolver.java @@ -2,11 +2,13 @@ package kr.xit.framework.support.exception.resolver; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.sql.SQLIntegrityConstraintViolationException; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.web.servlet.ModelAndView; import kr.xit.framework.support.util.AjaxMessageMapRenderer; @@ -26,19 +28,33 @@ public class NormalExceptionViewResolver extends AbstractExceptionViewResolver { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream pinrtStream = new PrintStream(out); - exception.printStackTrace(pinrtStream); String stackTraceString = ""; - if(Globals.IS_SP_ALERT_MSG) stackTraceString = out.toString(); Map tempMap = AjaxMessageMapRenderer.error(errorCode, errorArguments); + + tempMap.put("result", false); + exception.printStackTrace(pinrtStream); + if(Globals.IS_SP_ALERT_MSG) stackTraceString = out.toString(); + + // Duplicate exception + if(exception instanceof SQLIntegrityConstraintViolationException + || exception instanceof DataIntegrityViolationException){ + tempMap.put("message", "요청 처리에 실패하였습니다[이미 등록된 데이타 요청]"); + }else{ + if(Globals.IS_SP_ALERT_MSG){ + exception.printStackTrace(pinrtStream); + stackTraceString = out.toString(); + } + } + if(Globals.IS_SP_ALERT_MSG) tempMap.put("message", tempMap.get("message")+"\n"+stackTraceString); else tempMap.put("message", tempMap.get("message")); mav.addObject(Globals.JSON_ERROR_ROOT_ELEMENT_VALUE, tempMap); // mav.addObject(Globals.JSON_ERROR_ROOT_ELEMENT_VALUE, AjaxMessageMapRenderer.error(errorCode, errorArguments)); - Map errorMessage = AjaxMessageMapRenderer.error(errorCode, errorArguments); + - logger.error(new StringBuffer().append("error_code : {}\n").append("error_message : {}").toString(), - new Object[]{ errorCode, errorMessage}); + logger.error("error_code : {}\n" + "error_message : {}", + new Object[]{ errorCode, tempMap}); return mav; } diff --git a/src/main/resources/message/com/message-common.properties b/src/main/resources/message/com/message-common.properties index 6b64c387..f361995f 100644 --- a/src/main/resources/message/com/message-common.properties +++ b/src/main/resources/message/com/message-common.properties @@ -127,7 +127,7 @@ fail.common.loginIncorrect = [{0}] \uD68C \uC774\uC0C1 \uB85C\uADF8\uC778 \uC811 fail.common.login.password = \uD328\uC2A4\uC6CC\uB4DC \uC790\uB9AC \uC218\uAC00 \uC77C\uCE58 \uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.(8\uC790\uB9AC \uC774\uC0C1 20\uC790\uB9AC \uC774\uD558) fail.common.idsearch = \uC544\uC774\uB514\uB97C \uCC3E\uC744\uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.common.pwsearch = \uBE44\uBC00\uBC88\uD638\uB97C \uCC3E\uC744\uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -fail.request.msg = \uC694\uCCAD\uCC98\uB9AC\uB97C \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4. +fail.request.msg = \uC694\uCCAD \uCC98\uB9AC\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4. fail.common.login.ip = \uB4F1\uB85D\uB41C IP\uAC00 \uC544\uB2C8\uBBC0\uB85C \uB85C\uADF8\uC778\uC774 \uAC70\uBD80\uB418\uC5C8\uC2B5\uB2C8\uB2E4. #UI User Message# diff --git a/src/main/resources/message/com/message-common_ko.properties b/src/main/resources/message/com/message-common_ko.properties index 50f30e5f..1758b1ac 100644 --- a/src/main/resources/message/com/message-common_ko.properties +++ b/src/main/resources/message/com/message-common_ko.properties @@ -127,7 +127,7 @@ fail.common.loginIncorrect = [{0}] \uD68C \uC774\uC0C1 \uB85C\uADF8\uC778 \uC811 fail.common.login.password = \uD328\uC2A4\uC6CC\uB4DC \uC790\uB9AC \uC218\uAC00 \uC77C\uCE58 \uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.(8\uC790\uB9AC \uC774\uC0C1 20\uC790\uB9AC \uC774\uD558) fail.common.idsearch = \uC544\uC774\uB514\uB97C \uCC3E\uC744\uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.common.pwsearch = \uBE44\uBC00\uBC88\uD638\uB97C \uCC3E\uC744\uC218 \uC5C6\uC2B5\uB2C8\uB2E4. -fail.request.msg = \uC694\uCCAD\uCC98\uB9AC\uB97C \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4. +fail.request.msg = \uC694\uCCAD \uCC98\uB9AC\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4. fail.common.login.ip = \uB4F1\uB85D\uB41C IP\uAC00 \uC544\uB2C8\uBBC0\uB85C \uB85C\uADF8\uC778\uC774 \uAC70\uBD80\uB418\uC5C8\uC2B5\uB2C8\uB2E4. #UI User Message#