/// <summary> /// 判断是否为 BusinessException /// </summary> /// <param name="e"></param> /// <returns></returns> public static bool IsBusinessException(this Exception e) { string msg = e.GetFullInfo(); int indexOf_cStart = msg.IndexOf(BusinessException.cStart); int indexOf_cEnd = msg.IndexOf(BusinessException.cEnd); bool r = indexOf_cStart >= 0 && indexOf_cEnd > indexOf_cStart; return(r); }
/// <summary> /// 先判断是否为 BusinessException /// /// 若是 返回 BusinessException 信息 /// 否则 返回 GetFullInfo 信息 /// </summary> /// <param name="e"></param> /// <returns></returns> public static string GetInfo(this Exception e) { string msg = e.GetFullInfo(); if (e.IsBusinessException() == true) { int cStartIndex = msg.IndexOf(BusinessException.cStart) + 1; int cEndIndex = msg.IndexOf(BusinessException.cEnd); return(msg.Substring(cStartIndex, cEndIndex - cStartIndex)); } else { return(msg); } }