package com.tailbet.config; import com.tailbet.model.vo.R; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; /** * 全局异常处理 */ @Slf4j @RestControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(RuntimeException.class) public R handleRuntimeException(RuntimeException e) { log.error("业务异常: {}", e.getMessage()); return R.fail(e.getMessage()); } @ExceptionHandler(Exception.class) public R handleException(Exception e) { log.error("系统异常: {}", e.getMessage(), e); return R.fail("系统错误: " + e.getMessage()); } }