package com.kexue.skills.exception;

import com.kexue.skills.common.CommonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 维哥
 * @Description
 * @create 2025-02-25 15:49
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BizException.class)
    public CommonResult<String> handleBizException(BizException e) {
        if (e == null) {
            return CommonResult.success("未知错误");
        }
        e.printStackTrace();
        return CommonResult.success(e.getErrorCode(), e.getMessage());
    }

    // 其他异常处理...
}