package com.xunmei.common.core.exception;

import io.jsonwebtoken.lang.Objects;
import lombok.Getter;
import lombok.Setter;

/**
 * Tkk
 */
@Getter
@Setter
public class SystemException extends RuntimeException {

    private String errorCode;

    private Object[] params;

    public SystemException(final String errorCode) {
        super(errorCode);
        this.errorCode = errorCode;
    }

    public SystemException(final String errorCode, final Object... params) {
        super(errorCode);
        this.errorCode = errorCode;
        this.params = params;
    }

    public SystemException(final String errorCode, final Throwable cause) {
        super(cause);
        this.errorCode = errorCode;
    }

    public SystemException(final String errorCode, final Object[] params, final Throwable cause) {
        super(cause);
        this.errorCode = errorCode;
        this.params = params;
    }

    @Override
    public String toString() {
        return this.errorCode + " => " + Objects.nullSafeToString(this.params);
    }

    @Override
    public void printStackTrace() {
        super.printStackTrace();
    }
}
