|
@@ -2,12 +2,14 @@ package com.dskj.znzn.transData.common.exception;
|
|
|
|
|
|
import com.dskj.znzn.transData.common.base.R;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.jdbc.BadSqlGrammarException;
|
|
|
import org.springframework.validation.FieldError;
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
|
|
+import java.sql.SQLSyntaxErrorException;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
@@ -46,6 +48,18 @@ public class GloableException {
|
|
|
return R.error(errorMessage.toString());
|
|
|
}
|
|
|
|
|
|
+ @ExceptionHandler(BadSqlGrammarException.class)
|
|
|
+ @ResponseBody
|
|
|
+ public R sqlException(BadSqlGrammarException e) {
|
|
|
+ log.info("Exception: [{}]", e.getMessage());
|
|
|
+ log.error("Exception", e);
|
|
|
+ if (e.getMessage().contains("doesn't exist")) {
|
|
|
+ return R.error("当前风场不存在数据");
|
|
|
+ } else {
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@ExceptionHandler(Exception.class)
|
|
|
@ResponseBody
|
|
|
public R exception(Exception e) {
|