Commit 8a27fb64 authored by 赵啸非's avatar 赵啸非

提交配置校验

parent 1b00f31a
......@@ -25,8 +25,6 @@ import javax.servlet.http.HttpServletResponse;
@Slf4j
public class ExceptionHandle {
@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
......
......@@ -7,6 +7,7 @@ import com.mortals.framework.exception.AppException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.messaging.handler.annotation.support.MethodArgumentTypeMismatchException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -21,8 +22,6 @@ import javax.servlet.http.HttpServletResponse;
@Slf4j
public class ExceptionHandle {
@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
......@@ -43,14 +42,13 @@ public class ExceptionHandle {
stack.getClassName(), stack.getMethodName(), stack.getLineNumber(), e.getClass().getName());
AppException ex = (AppException) e;
ret.put(KEY_RESULT_MSG, ex.getMessage());
}
if (e instanceof HttpMessageNotReadableException) {
} else if (e instanceof HttpMessageNotReadableException || e instanceof MethodArgumentTypeMismatchException) {
log.error("[system error]", e);
response.setStatus(HttpStatus.HTTP_BAD_REQUEST);
ret.put(KEY_RESULT_MSG, "参数错误,"+ StrUtil.subBefore(e.getMessage(), ";", false));
ret.put(KEY_RESULT_MSG, "参数错误," + StrUtil.subBefore(e.getMessage(), ";", false));
} else {
log.error("[system error]", e);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
response.setStatus(HttpStatus.HTTP_BAD_REQUEST);
ret.put(KEY_RESULT_MSG, "未知错误!" + e.getMessage());
}
return ret.toJSONString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment