|
@@ -5,6 +5,9 @@ import org.apache.shiro.authz.AuthorizationException;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
|
|
+import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
|
|
|
+import org.springframework.validation.BindException;
|
|
|
|
|
+import org.springframework.validation.FieldError;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
@@ -47,6 +50,18 @@ public class SqxExceptionHandler {
|
|
|
return Result.error("没有权限,请联系管理员授权");
|
|
return Result.error("没有权限,请联系管理员授权");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @ExceptionHandler(BindException.class)
|
|
|
|
|
+ public Result bindException(BindException ex) {
|
|
|
|
|
+ FieldError fieldError = ex.getFieldError();
|
|
|
|
|
+ assert fieldError != null;
|
|
|
|
|
+ return Result.error(fieldError.getDefaultMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ExceptionHandler(HttpMessageNotReadableException.class)
|
|
|
|
|
+ public Result HttpMessageNotReadableException() {
|
|
|
|
|
+ return Result.error("请求参数缺失");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@ExceptionHandler(Exception.class)
|
|
@ExceptionHandler(Exception.class)
|
|
|
public Result handleException(Exception e){
|
|
public Result handleException(Exception e){
|
|
|
logger.error(e.getMessage(), e);
|
|
logger.error(e.getMessage(), e);
|