添加通用文件
This commit is contained in:
parent
c82da9ffb8
commit
772398d225
@ -0,0 +1,29 @@
|
|||||||
|
package iet.ustb.sf.exception;
|
||||||
|
|
||||||
|
import iet.ustb.sf.common.R;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局异常处理器
|
||||||
|
*
|
||||||
|
* @author huangge1199
|
||||||
|
* @since 2025/6/30 10:56:33
|
||||||
|
*/
|
||||||
|
@RestControllerAdvice
|
||||||
|
@Slf4j
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(MyException.class)
|
||||||
|
public R<?> businessExceptionHandler(MyException e) {
|
||||||
|
log.error("BusinessException", e);
|
||||||
|
return R.fail(e.getCode(), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(RuntimeException.class)
|
||||||
|
public R<?> businessExceptionHandler(RuntimeException e) {
|
||||||
|
log.error("RuntimeException", e);
|
||||||
|
return R.fail(ErrorCode.SYSTEM_ERROR, "系统错误");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user