//--------------------------------------------------------------------- public LineReaderException ExtraTextException(string message, string text) { // For readability, trim the text down to first 60 characters bool trimmed = false; const int displayLength = 60; if (text.Length > displayLength) { text = text.Substring(0, displayLength); trimmed = true; } // Also for readability, trim off from 1st newline or return char. int index = text.IndexOfAny(new char[] { '\n', '\r' }); if (index >= 0) { text = text.Substring(0, index); trimmed = true; } StringBuilder extraText = new StringBuilder(); extraText.AppendFormat("\"{0}\"", text); if (trimmed) { extraText.Append("..."); } MultiLineException innerException = new MultiLineException(message, extraText.ToString()); return(new LineReaderException(reader, innerException)); }
//--------------------------------------------------------------------- public MultiLineException(MultiLineText message, System.Exception innerException) : base(ConvertToString(message), innerException) { if (innerException == null) { SetMultiLineMessage(message, null); } else { MultiLineException inner = innerException as MultiLineException; if (inner != null) { SetMultiLineMessage(message, inner.MultiLineMessage); } else { SetMultiLineMessage(message, innerException.Message); } } }