package com.chinacreator.process.exception;

/**
 * @author zhengrong.yan
 * @date 2021/2/2 17:57
 */

public class BusinessException extends Exception
{
    private static final long serialVersionUID = -891645067431734237L;
    private String code;
    private String[] params;

    public String getCode() {
        return this.code;
    }

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

    public BusinessException(final String message, final Throwable t, final String... params) {
        super(message, t);
        this.params = params;
        if (t instanceof BusinessException) {
            this.code = ((BusinessException)t).getCode();
            this.params = ((BusinessException)t).getParams();
        }
        else {
            this.code = "8000";
        }
    }

    public BusinessException(final Throwable t, final String... params) {
        this(t.getMessage(), t, params);
    }

    public String[] getParams() {
        return this.params;
    }
}
