|
@@ -1,5 +1,6 @@
|
|
package com.caimei.www.config;
|
|
package com.caimei.www.config;
|
|
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -11,13 +12,14 @@ import reactor.core.publisher.Mono;
|
|
* @author : Charles
|
|
* @author : Charles
|
|
* @date : 2020/8/7
|
|
* @date : 2020/8/7
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@ControllerAdvice
|
|
@ControllerAdvice
|
|
public class CustomExceptionHandler {
|
|
public class CustomExceptionHandler {
|
|
|
|
|
|
@ExceptionHandler(Exception.class)
|
|
@ExceptionHandler(Exception.class)
|
|
public String convertExceptionMsg(Exception e) {
|
|
public String convertExceptionMsg(Exception e) {
|
|
//自定义逻辑,可返回其他值
|
|
//自定义逻辑,可返回其他值
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error("异常处理:", e);
|
|
return "error/404";
|
|
return "error/404";
|
|
}
|
|
}
|
|
|
|
|
|
@@ -25,6 +27,7 @@ public class CustomExceptionHandler {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public Mono<String> convertIllegalAccessError(Exception e) {
|
|
public Mono<String> convertIllegalAccessError(Exception e) {
|
|
//自定义逻辑,可返回其他值
|
|
//自定义逻辑,可返回其他值
|
|
|
|
+ log.error("异常处理:", e);
|
|
return Mono.just("illegal access");
|
|
return Mono.just("illegal access");
|
|
}
|
|
}
|
|
}
|
|
}
|