|
@@ -2,8 +2,11 @@ package com.fs.app.exception;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
|
+import com.fs.common.exception.ServiceException;
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
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;
|
|
@@ -17,6 +20,7 @@ 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;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@@ -86,4 +90,15 @@ public class FSExceptionHandler {
|
|
|
|
|
|
return R.error(e.getMessage());
|
|
return R.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 业务异常
|
|
|
|
+ */
|
|
|
|
+ @ExceptionHandler(ServiceException.class)
|
|
|
|
+ public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
|
|
|
|
+ {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ Integer code = e.getCode();
|
|
|
|
+ return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|