|
@@ -0,0 +1,32 @@
|
|
|
+package fcb.project.manager.base.exception;
|
|
|
+
|
|
|
+import fdage.back.sdk.base.entity.Result;
|
|
|
+import fdage.back.sdk.base.exception.CommonBaseException;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
+import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author abnerhou
|
|
|
+ * @date 2020/9/27 19:09
|
|
|
+ * @desciption
|
|
|
+ */
|
|
|
+@ControllerAdvice
|
|
|
+public class ControllerHanderException {
|
|
|
+
|
|
|
+ @ExceptionHandler(CommonBaseException.class)
|
|
|
+ @ResponseBody
|
|
|
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
|
+ //在这个方法里定义我们需要返回的格式
|
|
|
+// public Map<String, Object> handleUserNotExistException(CommonBaseException ex){
|
|
|
+ public Result handleUserNotExistException(CommonBaseException e){
|
|
|
+ /* Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("code", ex.getCode());
|
|
|
+ result.put("msg", ex.getMsg());
|
|
|
+ return result;*/
|
|
|
+ return Result.failure(null == e.getCode() ? Result.CODE_FAILURE : e.getCode(), e.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|