package com.yh.saas.plugin.news.exception;

import com.yh.saas.plugin.news.enums.NewsExceptionEnums;
import lombok.Getter;

/**
 * 运营后台自定义错误
 * 
 * @author SunTianjun
 */
@Getter
public class NewsException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	private final String code;

	private final String message;

	public NewsException(NewsExceptionEnums errorDefined) {
		super(errorDefined.getValue());

		this.code = errorDefined.getCode();
		this.message = errorDefined.getValue();
	}

	public NewsException(String code) {
		super(NewsExceptionEnums.fromCode(code).getValue());
		this.code = code;
		this.message = NewsExceptionEnums.fromCode(code).getValue();
	}
}
