|
@@ -17,6 +17,8 @@ import com.ruoyi.common.exception.CustomException;
|
|
|
import com.ruoyi.common.exception.DemoModeException;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
|
+import javax.validation.ConstraintViolationException;
|
|
|
+
|
|
|
/**
|
|
|
* 全局异常处理器
|
|
|
*
|
|
@@ -95,6 +97,16 @@ public class GlobalExceptionHandler
|
|
|
return AjaxResult.error(message);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 自定义验证异常
|
|
|
+ */
|
|
|
+ @ExceptionHandler(ConstraintViolationException.class)
|
|
|
+ public AjaxResult constraintViolationException(ConstraintViolationException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ String message = e.getConstraintViolations().iterator().next().getMessage();
|
|
|
+ return AjaxResult.error(message);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 自定义验证异常
|
|
|
*/
|