Skip to content

Commit

Permalink
异常提示过多bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NiccoloTang committed Apr 2, 2017
1 parent b785cfb commit 048c8d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions api/src/main/java/cn/crap/framework/base/BaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ protected HashMap<String, String> getRequestParams() {
public JsonResult expHandler(HttpServletRequest request, Exception ex) {
if (ex instanceof MyException) {
return new JsonResult((MyException) ex);
} else if (ex instanceof NullPointerException) {
log.error(ex.getMessage(), ex);
}else if (ex instanceof NullPointerException) {
return new JsonResult(new MyException("000051"));
} else {
}else {
log.error(ex.getMessage(), ex);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand All @@ -139,15 +138,14 @@ public JsonResult expHandler(HttpServletRequest request, Exception ex) {

String cusedBy = "";
if (exceptionDetail.length > 0) {
cusedBy = exceptionDetail[exceptionDetail.length - 1];
cusedBy = exceptionDetail[exceptionDetail.length - 1].split("\n")[0];
}

// 字段超过最大长度异常处理
if (ex instanceof DataIntegrityViolationException) {
if (cusedBy.contains("com.mysql.jdbc.MysqlDataTruncation")) {
return new JsonResult(new MyException("000052", "(字段:" + cusedBy.split("'")[1] + ")"));
}

}

return new JsonResult(new MyException("000001", ex.getMessage() + "——" + cusedBy));
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/webapp/resources/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ function closeTip(data,iLoading,tipTime){
}
}
if(iLoading.toUpperCase().indexOf('TIP') >= 0){
// 需要先赋值才能获取浏览宽度
if(tipMessage!=""){
if(tipMessage!="false"&&tipMessage!=false)
$("#tip-div").html(tipMessage);
}
$("#tip-div").css("left", ($(window).width()/2 - $("#tip-div").width()/2) +"px");
showMessage("tip-div",tipMessage,false,tipTime);
}
}
Expand Down

0 comments on commit 048c8d7

Please sign in to comment.