新增全局报错处理统 优化代码结构 article基础代码完成

This commit is contained in:
qingfeng1121
2025-10-09 17:22:00 +08:00
parent 6841ba67f1
commit 92c604e1f5
7 changed files with 119 additions and 16 deletions

View File

@@ -0,0 +1,13 @@
package com.qf.myafterprojecy;
import com.qf.myafterprojecy.pojo.ResponseMessage;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(value=Exception.class)
public ResponseMessage<String> handleException(Exception e){
return new ResponseMessage<>(500,"服务器异常",e.getMessage());
}
}