package sgc.portal.base.exception;

import sgc.portal.base.error.I18nErrorMessageResolver;
import sgc.portal.base.i18n.I18nMessage;
import sgc.portal.base.exception.advice.ErrorConst;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.MessageSource;

/**
 * JAVA BUSINESS ERROR
 *
 * @author beomgeun.lee
 * @version 1.0.0
 * @see I18nMessage
 * @see I18nErrorMessageResolver
 * @since 2019. 11. 19.
 */
@Getter
@Setter
@SuppressWarnings("serial")
public class BusinessException extends RuntimeException {
    private MessageSource messageSource;
    private int errorCode = ErrorConst.USER_DEFINE_ERROR;

    /**
     * The Buis error code.
     */
    private String buisErrorCode;
    /**
     * The Buis message.
     */
    private String buisMessage;
    /**
     * The Message.
     */
    private String message;

    private I18nMessage i18nMessage;

    /**
     * Instantiates a new Business exception.
     *
     * @param cause the cause
     */
    public BusinessException(Throwable cause) {
        super(cause);
    }

    /**
     * Instantiates a new Business exception.
     *
     * @param buisMessage the buis message
     */
    public BusinessException(String buisMessage) {
        super(buisMessage);
        this.buisErrorCode = "error";
        this.buisMessage = buisMessage;
    }

    /**
     * Instantiates a new Business exception.
     *
     * @param buisErrorCode the buis error code
     * @param buisMessage   the buis message
     */
    public BusinessException(String buisErrorCode, String buisMessage) {
        super(buisMessage);
        this.buisErrorCode = buisErrorCode;
        this.buisMessage = buisMessage;
    }

    /**
     * Instantiates a new Business exception.
     *
     * @param buisErrorCode the buis error code
     * @param buisMessage   the buis message
     * @param cause         the cause
     */
    public BusinessException(String buisErrorCode, String buisMessage, Throwable cause) {
        super(cause);
        this.buisErrorCode = buisErrorCode;
        this.buisMessage = buisMessage;
    }


    /**
     * Instantiates a new Business exception.
     *
     * @param i18nMessage the 18 n message
     */
    public BusinessException(I18nMessage i18nMessage) {
        super();
        this.buisErrorCode = "error";
        this.i18nMessage = i18nMessage;
    }

    /**
     * Instantiates a new Business exception.
     *
     * @param buisErrorCode the buis error code
     * @param i18nMessage   the 18 n message
     */
    public BusinessException(String buisErrorCode, I18nMessage i18nMessage) {
        super();
        this.buisErrorCode = buisErrorCode;
        this.i18nMessage = i18nMessage;
    }

    /**
     * Instantiates a new Business exception.
     *
     * @param i18nMessage the 18 n message
     * @param cause       the cause
     */
    public BusinessException(I18nMessage i18nMessage, Throwable cause) {
        super(cause);
        this.buisErrorCode = "error";
        this.i18nMessage = i18nMessage;
    }

}