//------------------------------------------------------------ // CSResources.FormatErrorMessage (2) // /// <summary> /// <para>Get the format string by id, create an error message with args and locations</para> /// </summary> /// <param name="excp"></param> /// <param name="errorNo"></param> /// <param name="strID"></param> /// <param name="errorKind"></param> /// <param name="fileName"></param> /// <param name="line"></param> /// <param name="col"></param> /// <param name="lineEnd"></param> /// <param name="colEnd"></param> /// <param name="args"></param> /// <returns></returns> //------------------------------------------------------------ static internal string FormatErrorMessage( out Exception excp, ERRORKIND errorKind, string prefix, int errorNo, ResNo resNo, string fileName, int line, int col, int lineEnd, int colEnd, params Object[] args) { string message = null; if (!ErrorUtil.FormatErrorMessage(out message, out excp, resNo, args) && String.IsNullOrEmpty(message)) { // If failed to format, concatenate args to create a message. if (args.Length > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < args.Length; ++i) { string str = args[i].ToString(); if (!String.IsNullOrEmpty(str)) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(str); } } if (sb.Length > 0) { message = sb.ToString(); } } if (String.IsNullOrEmpty(message)) { message = "Unknown error."; } } return(FormatStringUtil.FormatErrorMessageCore( fileName, line, col, lineEnd, colEnd, errorKind, prefix, errorNo, message)); }
//------------------------------------------------------------ // BCErrorInfoManager.FormatErrorMessage (2) // /// <summary> /// <para>Get the format string by id, /// create an error message with args and locations</para> /// </summary> /// <param name="excp"></param> /// <param name="errID"></param> /// <param name="errKind"></param> /// <param name="fileName"></param> /// <param name="lineStart"></param> /// <param name="colStart"></param> /// <param name="lineEnd"></param> /// <param name="colEnd"></param> /// <param name="args"></param> /// <returns></returns> //------------------------------------------------------------ internal string FormatErrorMessage( out Exception excp, ERRID errID, ERRORKIND errKind, string fileName, int lineStart, int colStart, int lineEnd, int colEnd, params Object[] args) { int errorNo = -1; ResNo resNo = ResNo.Invalid; ERRORINFO eInfo = GetInfo(errID); if (eInfo != null) { errorNo = eInfo.ErrorNumber; resNo = eInfo.ResourceNumber; if (!ErrorUtil.IsValidErrorKind(errKind)) { errKind = ErrorUtil.GetErrorKind(eInfo.WarningLevel); } } else { resNo = ResNo.CSCSTR_InternalError; args = new Object[] { "invalid error ID in CSResources.FormatErrorMessage" }; } return(ErrorUtil.FormatErrorMessage( out excp, errKind, this.Prefix, errorNo, resNo, fileName, lineStart, colStart, lineEnd, colEnd, args)); }
//------------------------------------------------------------ // BCErrorInfoManager.FormatErrorMessage (1) // /// <summary> /// <para>Get the format string by id, /// create an error message with args</para> /// </summary> /// <param name="formatted"></param> /// <param name="excp"></param> /// <param name="errID"></param> /// <param name="args"></param> /// <returns></returns> //------------------------------------------------------------ internal bool FormatErrorMessage( out string formatted, out Exception excp, ERRID errID, params Object[] args) { ResNo resNo; formatted = null; excp = null; if (GetResourceNumber(errID, out resNo)) { return(ErrorUtil.FormatErrorMessage( out formatted, out excp, resNo, args)); } return(false); }