tlias管理系统-全局异常处理器功能实现
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.inmind.exception;
|
||||
|
||||
import com.inmind.pojo.Result;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice//配置为全局异常处理器
|
||||
public class GlobalException {
|
||||
|
||||
/*
|
||||
定义一个全局异常处理的方法:只要出现异常就会被ex方法处理
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result ex(Exception e){
|
||||
e.printStackTrace();
|
||||
//日志框架logback,把异常信息保存到日志文件
|
||||
return Result.error("对不起,服务器报错,请联系管理员");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user