tlias管理系统--全局异常处理
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
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 GlobaException {
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)//针对哪些异常会进行处理,直接处理所有异常
|
||||||
|
public Result handleException(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.error("对不起,服务器报错,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user