From 0631085681b5a3248bbdfb99f061257da7ccbf3b Mon Sep 17 00:00:00 2001 From: Eq Zhan <35362437+pingxingshikong@users.noreply.github.com> Date: Wed, 16 Jun 2021 10:22:55 +0800 Subject: [PATCH] update exceptionAdvice --- .../syncer/syncerpluswebapp/advice/ExceptionAdvice.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/syncer-webapp/src/main/java/syncer/syncerpluswebapp/advice/ExceptionAdvice.java b/syncer-webapp/src/main/java/syncer/syncerpluswebapp/advice/ExceptionAdvice.java index a90e0488..fb253c26 100644 --- a/syncer-webapp/src/main/java/syncer/syncerpluswebapp/advice/ExceptionAdvice.java +++ b/syncer-webapp/src/main/java/syncer/syncerpluswebapp/advice/ExceptionAdvice.java @@ -71,6 +71,7 @@ public ResultMap ConnectException(ConnectException e){ */ @ExceptionHandler(ConstraintViolationException.class) public ResultMap ConstraintViolationException(ConstraintViolationException e){ + log.warn(e.getMessage()); List errorInformation = new ArrayList(e.getConstraintViolations()); return ResultMap.builder().code(CodeConstant.VALITOR_ERROR_CODE) .msg(errorInformation.get(0).getMessage()); @@ -83,6 +84,7 @@ public ResultMap ConstraintViolationException(ConstraintViolationException e){ */ @ExceptionHandler(BindException.class) public ResultMap BindException(BindException e){ + log.warn(e.getMessage()); List errorInformation = e.getBindingResult().getAllErrors() .stream() .map(ObjectError::getDefaultMessage) @@ -100,6 +102,7 @@ public ResultMap BindException(BindException e){ */ @ExceptionHandler(MethodArgumentNotValidException.class) public ResultMap MethodArgumentNotValidException(MethodArgumentNotValidException e){ + log.warn(e.getMessage()); String msg = msgConvertor(((MethodArgumentNotValidException) e).getBindingResult()); return ResultMap.builder().code(CodeConstant.VALITOR_ERROR_CODE) .msg(msg); @@ -165,7 +168,8 @@ public ResultMap TaskMsgException(TaskMsgException e){ * @return */ @ExceptionHandler(HttpMessageNotReadableException.class) - public ResultMap HttpMessageNotReadableException(){ + public ResultMap HttpMessageNotReadableException(HttpMessageNotReadableException e){ + log.warn(e.getMessage()); return ResultMap.builder().code(CodeConstant.HTTP_MSG_PARSE_ERROR_CODE) .msg(HttpMsgConstant.HTTP_MSG_PARSE_ERROR_CODE); } @@ -175,7 +179,8 @@ public ResultMap HttpMessageNotReadableException(){ * @return */ @ExceptionHandler(Exception.class) - public ResultMap Exception(){ + public ResultMap Exception(Exception e){ + log.warn(e.getMessage()); return ResultMap.builder().code(CodeConstant.HTTP_ERROR_CODE) .msg(HttpMsgConstant.HTTP_ERROR_MESSAGE); }