Logger和Exception

public class PayException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2373806520202646197L;

	/**
	 * 异常消息号
	 */
	private int msgId;

	/**
	 * 一般性错误,依赖消息
	 */
	public static final int NORMAL_ERROR = -1;

	/**
	 * 登陆账号异常
	 */
	public static final int YIXIN_ACCOUNTID_ERROR = -2;

	/**
	 * 生成签名失败
	 */
	public static final int GENERATE_SIGNATURE_FAIL = -3;

	/**
	 * 验证签名失败
	 */
	public static final int VERIFY_SIGNATURE_FAIL = -4;

	/**
	 * 商品不存在
	 */
	public static final int GOODS_NOT_EXIST = -5;

	/**
	 * 订单不存在
	 */
	public static final int TRADE_NOT_EXIST = -6;

	/**
	 * 支付方式错误
	 */
	public static final int PAYMETHOD_ERROR = -7;

	/**
	 * 参数非法
	 */
	public static final int PARAMETER_ILLEGAL = -8;

	/**
	 * 超时
	 */
	public static final int TIMEOUT_ERROR = -9;
	
	
	/**
	 * 更新PayToolType失败
	 */
	public static final int UPDATE_PAYTOOLTYPE_FAIL = -10;

	/**
	 * 第三方订单号重复
	 */
	public static final int THIRDPART_ORDERID_DUPLICATED = -31;

	/**
	 * 支付工具通知的支付状态非法
	 */
	public static final int PAYTOOL_PAY_STATUS_ERROR = -51;

	/**
	 * 数据库异常
	 */
	public static final int DDB_EXCEPTION = -101;
	
	/**
	 * 代金券状态异常
	 */
	public static final int VOUCHER_STATUS_EXCEPTION = -2001;
	
	/**
	 * 支付停用
	 */
	public static final int PAY_STOP = -1001;

	public static final Map<Integer, String> TIPS = new HashMap<Integer, String>();

	static {
		TIPS.put(NORMAL_ERROR, "支付请求失败,请重试");
		TIPS.put(YIXIN_ACCOUNTID_ERROR, "账号登录失败,请重试");
		TIPS.put(GENERATE_SIGNATURE_FAIL, "生成签名失败,请重试");
		TIPS.put(VERIFY_SIGNATURE_FAIL, "验证签名失败,请重试");
		TIPS.put(GOODS_NOT_EXIST, "商品不存在,请重试");
		TIPS.put(TRADE_NOT_EXIST, "订单不存在,请重试");
		TIPS.put(PAYMETHOD_ERROR, "支付方式错误,请重试");
		TIPS.put(PARAMETER_ILLEGAL, "参数非法");
		TIPS.put(TIMEOUT_ERROR, "支付超时,请重新支付");
		TIPS.put(THIRDPART_ORDERID_DUPLICATED, "订单重复");
		TIPS.put(PAYTOOL_PAY_STATUS_ERROR, "无效订单");
		TIPS.put(DDB_EXCEPTION, "支付数据请求失败,请重试");
		TIPS.put(UPDATE_PAYTOOLTYPE_FAIL, "更新PayToolType失败");
		TIPS.put(VOUCHER_STATUS_EXCEPTION, "您的代金券状态异常,请联系客服解决");
	}

	/**
	 * 构造函数
	 * 
	 * @param msg
	 *            消息ID
	 */
	public PayException(int msg) {
		super();
		this.msgId = msg;
	}

	/**
	 * 构造函数
	 * 
	 * @param msg
	 *            消息ID
	 * @param cause
	 *            父异常对象
	 */
	public PayException(int msg, Throwable cause) {
		super(cause);
		this.msgId = msg;
	}

	/**
	 * 构造函数
	 * 
	 * @param msg
	 *            消息ID
	 * @param content
	 *            消息内容
	 */
	public PayException(int msg, String content) {
		super(content);
		this.msgId = msg;
	}

	/**
	 * 构造函数
	 * 
	 * @param msg
	 *            消息ID
	 * @param content
	 *            消息内容
	 */
	public PayException(int msg, String content, Throwable cause) {
		super(content, cause);
		this.msgId = msg;
	}

	public int getMsgId() {
		return msgId;
	}

	public void setMsgId(int msgId) {
		this.msgId = msgId;
	}

}

 以上是自己写Exception代码,如果我们写Logger的话,我们直接

private static final Logger logger = Logger.getLogger(PayController.class);

private static final Logger payLogger = Logger.getLogger("PayLog");

 

logger.error("accessToken=" + accessToken);
payLogger.error("accessToken=" + accessToken);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值