package com.hfkj.common.exception;

public class ErrorHelp {

    public static BaseException genException(SysCode sc, ErrorCode ec, Object... args){
        String errorCode = sc.getCode()+ec.getCode();
        StringBuilder sb = new StringBuilder();
        if (args != null && args.length != 0) {
			for(Object o : args){
				sb.append(o.toString());
			}
		}
        String errorMsg = ec.getMsg()+sb.toString();//@TODO 这里需要处理变参
        char a = ec.getCode().charAt(0);
        if (a == '0') {//系统异常
            return new SysException(errorCode,errorMsg);
        } else if (a == '1') {//APP异常
            return new AppException(errorCode,errorMsg);
        } else {//业务异常
            return new BizException(errorCode,errorMsg);
        }
    }
}
