package com.yaoai.common.exception;

import lombok.Getter;

/**
 * 业务异常 — 由 GlobalExceptionHandler 捕获并转换为 ApiResponse.error
 */
@Getter
public class BizException extends RuntimeException {

    private final String code;

    public BizException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public BizException(String code, String message) {
        super(message);
        this.code = code;
    }

    public BizException(ErrorCode errorCode, String extraMessage) {
        super(errorCode.getMessage() + ": " + extraMessage);
        this.code = errorCode.getCode();
    }
}
