|
@@ -9,6 +9,7 @@ import com.zhichen.common.exception.DemoModeException;
|
|
import io.jsonwebtoken.ExpiredJwtException;
|
|
import io.jsonwebtoken.ExpiredJwtException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
import org.springframework.security.access.AccessDeniedException;
|
|
import org.springframework.security.access.AccessDeniedException;
|
|
import org.springframework.security.authentication.AccountExpiredException;
|
|
import org.springframework.security.authentication.AccountExpiredException;
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
@@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
|
|
|
|
import javax.validation.ConstraintViolationException;
|
|
import javax.validation.ConstraintViolationException;
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 全局异常处理器
|
|
* 全局异常处理器
|
|
@@ -52,6 +54,16 @@ public class GlobalExceptionHandler
|
|
return AjaxResult.error(e.getCode(), e.getMessage());
|
|
return AjaxResult.error(e.getCode(), e.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * sql错误
|
|
|
|
+ */
|
|
|
|
+ @ExceptionHandler({SQLException.class, DataAccessException.class})
|
|
|
|
+ public AjaxResult handleAllSqlExceptions(Exception e)
|
|
|
|
+ {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ return AjaxResult.error(HttpStatus.HTTP_INTERNAL_ERROR, "非法操作,请稍后再试");
|
|
|
|
+ }
|
|
|
|
+
|
|
@ExceptionHandler(NoHandlerFoundException.class)
|
|
@ExceptionHandler(NoHandlerFoundException.class)
|
|
public AjaxResult handlerNoFoundException(Exception e)
|
|
public AjaxResult handlerNoFoundException(Exception e)
|
|
{
|
|
{
|