tlias管理系统--全局异常处理

This commit is contained in:
2025-12-07 14:12:22 +08:00
parent 203bbd5838
commit a10456f024

View File

@@ -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("对不起,服务器报错,请联系管理员");
}
}