package sgc.portal.base.exception;

import sgc.portal.base.exception.advice.ErrorConst;

import java.util.Arrays;

/**
 * Session Time Out Exception
 *
 * @author USER
 */
public class SessionTimeoutException extends RuntimeException {

	
    /**
     * default serialVersionUID.
     */
    private static final long serialVersionUID = 1L;

    private int errorCode = ErrorConst.DEFAULT_ERROR;

    /** code. */
    private String code;
    /** arguments. */
    private Object[] arguments;

    /**
     * code를 받는 생성자.
     *
     * @param code code
     * @return
     */
    public SessionTimeoutException(final String code) {
        this.code = code;
    }

    /**
     * code 와 argument를 받는 생성자.
     *
     * @param code      code
     * @param arguments arguments
     * @return
     */
    public SessionTimeoutException(final String code, final Object... arguments) {
        this.code = code;
        this.arguments = arguments.clone();
    }

    /**
     * getter.
     *
     * @return String code
     */
    public String getCode() {
        return code;
    }

    /**
     * SETTER.
     *
     * @param code code
     */
    public void setCode(final String code) {
        this.code = code;
    }

    /**
     * GETTER.
     *
     * @return Object object [ ]
     */
    public Object[] getArguments() {
        if(arguments == null){
            return null;
        }else{
            return arguments.clone();
        }
    }

    /**
     * SETTER.
     *
     * @param arguments arguments
     */
    public void setArguments(final Object... arguments) {
        this.arguments = arguments.clone();
    }

    /**
     * Gets error code.
     *
     * @return the error code
     */
    public int getErrorCode() {
        return errorCode;
    }

    /**
     * Sets error code.
     *
     * @param errorCode the error code
     */
    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    @Override
    public final String toString() {
        return "NestedRuntimeException [code=" + code + ", arguments=" + Arrays.toString(arguments) + "]";
    }

    @Override
    public final String getMessage() {
        return "NestedRuntimeException [code=" + code + ", arguments=" + Arrays.toString(arguments) + "]";
    }

}
