package com.jeequan.jeepay.core.exception;

import com.jeequan.jeepay.core.model.rqrs.msg.ChannelRetMsg;
import lombok.Getter;

/*
* 请求渠道侧异常 exception
* 抛出此异常： 仅支持：  未知状态（需查单） 和 系统内异常
*
* @author terrfly
*
* @date 2021/6/8 17:28
*/
@Getter
public class ChannelException extends RuntimeException{

	private static final long serialVersionUID = 1L;

	private ChannelRetMsg channelRetMsg;

	/** 业务自定义异常 **/
	public ChannelException(ChannelRetMsg channelRetMsg) {
		super(channelRetMsg != null ? channelRetMsg.getChannelErrMsg() : null);
		this.channelRetMsg = channelRetMsg;
	}

	/** 未知状态 **/
	public static ChannelException unknown(String channelErrMsg){
		return new ChannelException(ChannelRetMsg.unknown(channelErrMsg));
	}

	/** 系统内异常 **/
	public static ChannelException sysError(String channelErrMsg){
		return new ChannelException(ChannelRetMsg.sysError(channelErrMsg));
	}
}
