public static void Ctor_String_Exception()
 {
     string message = "This path is too long to hike in a single day.";
     var innerException = new Exception("Inner exception");
     var exception = new PathTooLongException(message, innerException);
     ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_PATHTOOLONG, innerException: innerException, message: message);
 }
 protected override void LogPathToLoog(string fullName, PathTooLongException ex)
 {
     this.xmlWriter.WriteStartElement("pathTooLong");
     this.xmlWriter.WriteAttributeString("path", fullName);
     this.xmlWriter.WriteAttributeString("message", ex.Message);
     this.xmlWriter.WriteEndElement();
 }
Example #3
0
 /// <summary>
 /// The idea here is to show a helpful notice, with the option to click "REPORT" if they need help.
 /// </summary>
 /// <param name="e">either a raw PathTooLongException or our own enhanced subclass</param>
 internal static void ReportLongPath(System.IO.PathTooLongException e)
 {
     // If we have our own subclass, it will know the path of the offending file and maybe more helpful info.
     if (e is Bloom.Utils.PathTooLongException)
     {
         var x = (Bloom.Utils.PathTooLongException)e;
         ErrorReport.NotifyUserOfProblem(x, $"{GetGenericPathTooLongMessage()} <br> <span style='font-size:7pt'>Path was '{x.Path}'. {x.AdditionalInfo}</span>");
     }
     else
     {
         ErrorReport.NotifyUserOfProblem(e, $"{GetGenericPathTooLongMessage()}");
     }
 }
 protected override void LogPathToLoog(string fullName, PathTooLongException ex)
 {
     this.currentParent.Add(new XElement(
         "pathTooLong"
         , new XAttribute("message", ex.Message)));
 }
 public static void Ctor_Empty()
 {
     var exception = new PathTooLongException();
     ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_PATHTOOLONG, validateMessage: false);
 }
Example #6
0
 protected abstract void LogPathToLoog(string fullName, PathTooLongException ex);
Example #7
0
        public void ExceptionTests()
        {
            using (new InternalLoggerScope())
            {
                InternalLogger.LogLevel = LogLevel.Trace;
                InternalLogger.LogToConsole = true;
                InternalLogger.IncludeTimestamp = false;

                var ex1 = new Exception("e1");
                var ex2 = new Exception("e2", new Exception("inner"));
                var ex3 = new NLogConfigurationException("config error");
                var ex4 = new NLogConfigurationException("config error", ex2);
                var ex5 = new PathTooLongException();
                ex5.Data["key1"] = "value1";
                Exception ex6 = null;

                const string prefix = " Exception: ";
                string expected =
                    "Warn WWW" + prefix + ex1 + Environment.NewLine +
                    "Error EEE" + prefix + ex2 + Environment.NewLine +
                    "Fatal FFF" + prefix + ex3 + Environment.NewLine +
                    "Trace TTT" + prefix + ex4 + Environment.NewLine +
                    "Debug DDD" + prefix + ex5 + Environment.NewLine +
                    "Info III" + Environment.NewLine;

                StringWriter consoleOutWriter = new StringWriter()
                {
                    NewLine = Environment.NewLine
                };

                // Redirect the console output to a StringWriter.
                Console.SetOut(consoleOutWriter);

                // Named (based on LogLevel) public methods.

                InternalLogger.Warn(ex1, "WWW");
                InternalLogger.Error(ex2, "EEE");
                InternalLogger.Fatal(ex3, "FFF");
                InternalLogger.Trace(ex4, "TTT");
                InternalLogger.Debug(ex5, "DDD");
                InternalLogger.Info(ex6, "III");

                consoleOutWriter.Flush();
                var strings = consoleOutWriter.ToString();
                Assert.Equal(expected, strings);
            }

        }
 public static void Handle(PathTooLongException exception)
 {
     ConsoleLogExceptionMessage(exception);
 }
 public ProjectExceptions(string errorText, PathTooLongException innerException)
     : base(errorText, innerException)
 {
 }