新增全局报错处理统 优化代码结构 article基础代码完成
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user