|
@@ -36,9 +36,10 @@ public class CommonExceptionHandler {
|
|
|
for (FieldError fieldError : ex.getBindingResult().getFieldErrors()) {
|
|
|
stringMap.put(fieldError.getField(), fieldError.getDefaultMessage());
|
|
|
}
|
|
|
- log.warn("【参数异常】:", ex.getBindingResult());
|
|
|
+ String msg = GsonUtil.toJson(stringMap);
|
|
|
+ log.warn("【参数异常】:{}", msg);
|
|
|
resp.code = CommonErrorCode.PARAM_ERROR.getCode();
|
|
|
- resp.msg = GsonUtil.toJson(stringMap);
|
|
|
+ resp.msg = msg;
|
|
|
return new ResponseEntity(resp, HttpStatus.OK);
|
|
|
}
|
|
|
if(e instanceof MethodArgumentNotValidException) {
|
|
@@ -47,29 +48,32 @@ public class CommonExceptionHandler {
|
|
|
for (FieldError fieldError : ex.getBindingResult().getFieldErrors()) {
|
|
|
stringMap.put(fieldError.getField(), fieldError.getDefaultMessage());
|
|
|
}
|
|
|
- log.warn("【参数异常】:", ex.getBindingResult());
|
|
|
+ String msg = GsonUtil.toJson(stringMap);
|
|
|
+ log.warn("【参数异常】:{}", msg);
|
|
|
resp.code = CommonErrorCode.PARAM_ERROR.getCode();
|
|
|
- resp.msg = GsonUtil.toJson(stringMap);
|
|
|
+ resp.msg = msg;
|
|
|
return new ResponseEntity(resp, HttpStatus.OK);
|
|
|
}
|
|
|
if(e instanceof MissingServletRequestParameterException) {
|
|
|
MissingServletRequestParameterException ex = (MissingServletRequestParameterException) e;
|
|
|
Map<String, String> stringMap = new HashMap<>();
|
|
|
stringMap.put(ex.getParameterName(), "不能为null");
|
|
|
+ String msg = GsonUtil.toJson(stringMap);
|
|
|
+ log.warn("【参数异常】:{}", msg);
|
|
|
resp.code = CommonErrorCode.PARAM_ERROR.getCode();
|
|
|
- resp.msg = GsonUtil.toJson(stringMap);
|
|
|
+ resp.msg = msg;
|
|
|
return new ResponseEntity(resp, HttpStatus.OK);
|
|
|
}
|
|
|
if(e instanceof CommonException) {
|
|
|
CommonException taiChiException = (CommonException) e;
|
|
|
resp.code = taiChiException.getCode();
|
|
|
resp.msg = e.getMessage();
|
|
|
- log.error("【业务异常】:" + e.getMessage());
|
|
|
+ log.error("【业务异常】:{}", e.getMessage());
|
|
|
return new ResponseEntity(resp, HttpStatus.OK);
|
|
|
}
|
|
|
resp.code = CommonErrorCode.FAIL.getCode();
|
|
|
resp.msg = e.getMessage();
|
|
|
- log.error("【系统异常】:" + e.getMessage());
|
|
|
+ log.error("【系统异常】:{}", e.getMessage());
|
|
|
e.printStackTrace();
|
|
|
return new ResponseEntity(resp, HttpStatus.OK);
|
|
|
}
|