|
@@ -1,23 +1,18 @@
|
|
|
-/*
|
|
|
- * *************************************************
|
|
|
- * Copyright (c) 2018 QMTH. All Rights Reserved.
|
|
|
- * Created by Deason on 2018-07-16 15:59:42.
|
|
|
- * *************************************************
|
|
|
- */
|
|
|
-
|
|
|
-package cn.com.qmth.examcloud.app.core.aspect;
|
|
|
+package cn.com.qmth.examcloud.app.core.config;
|
|
|
|
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
-@ControllerAdvice(annotations = Controller.class)
|
|
|
-public class ControllerAspect {
|
|
|
- private final static Logger log = LoggerFactory.getLogger(ControllerAspect.class);
|
|
|
+@ResponseBody
|
|
|
+@ControllerAdvice
|
|
|
+public class ControllerAdviceHandler {
|
|
|
+
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(ControllerAdviceHandler.class);
|
|
|
|
|
|
@ResponseBody
|
|
|
@ExceptionHandler(value = RuntimeException.class)
|
|
@@ -33,4 +28,11 @@ public class ControllerAspect {
|
|
|
return new Result().error(e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ @ResponseBody
|
|
|
+ @ExceptionHandler(value = StatusException.class)
|
|
|
+ public Result handle(StatusException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ return new Result().error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
}
|