BusinessException.java 1.0 KB
package com.aigeo.common.exception;

import com.aigeo.common.result.ResultCode;
import lombok.Getter;

/**
 * 业务异常类
 *
 * @author AIGEO Team
 * @since 1.0.0
 */
@Getter
public class BusinessException extends RuntimeException {
    
    private final Integer code;
    private final String message;

    public BusinessException(String message) {
        super(message);
        this.code = ResultCode.BUSINESS_ERROR.getCode();
        this.message = message;
    }

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

    public BusinessException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public BusinessException(ResultCode resultCode, String message) {
        super(message);
        this.code = resultCode.getCode();
        this.message = message;
    }

    public Integer getResultCode() {
        return this.code;
    }
}