Пример #1
0
		/* Function: HandleException
		 */
		static private void HandleException (Exception e)
			{
			var errorOutput = Console.Error;

			errorOutput.Write ("\n\n------------------------------------------------------------\n");
			errorOutput.WriteLine (Locale.SafeGet("NaturalDocs.CLI", "Crash.Exception",
																	"Natural Docs has closed because of the following error:"));
			errorOutput.WriteLine();


			// If it's a user friendly exception, just display it

			if ( e.GetType() == typeof(Engine.Exceptions.UserFriendly) ||
				 ( e.GetType() == typeof(Engine.Exceptions.Thread) &&
				   e.InnerException.GetType() == typeof(Engine.Exceptions.UserFriendly) ))
				{
				errorOutput.WriteLine(e.Message);
				}

			else
				{
				Path crashFile = EngineInstance.BuildCrashReport(e);


				// If we were able to build a crash report, display the exception and the report's location

				if (crashFile != null)
					{
					errorOutput.WriteLine(e.Message);
					errorOutput.WriteLine();
					errorOutput.Write (Locale.SafeGet("NaturalDocs.CLI", "Crash.ReportAt(file).multiline", 
																	  "A crash report has been generated at {0}.\n" +
																	  "Please include this file when asking for help at naturaldocs.org.\n", crashFile));
					}


				// If we couldn't build the crash report, display the information on the screen.
					
				else
					{
					errorOutput.Write( EngineInstance.GetCrashInformation(e) );
					errorOutput.WriteLine ();
					errorOutput.WriteLine (Locale.SafeGet("NaturalDocs.CLI", "Crash.IncludeInfoAndGetHelp",
																			"Please include this information when asking for help at naturaldocs.org."));
					}
				}

			errorOutput.Write ("------------------------------------------------------------\n\n");
			}
Пример #2
0
        /* Function: HandleException
         */
        static private void HandleException(Exception e)
        {
            var errorOutput = Console.Error;

            errorOutput.Write("\n\n------------------------------------------------------------\n");
            errorOutput.WriteLine(Locale.SafeGet("NaturalDocs.CLI", "Crash.Exception",
                                                 "Natural Docs has closed because of the following error:"));
            errorOutput.WriteLine();


            // If it's a user friendly exception, just display it

            if (e.GetType() == typeof(Engine.Exceptions.UserFriendly) ||
                (e.GetType() == typeof(Engine.Exceptions.Thread) &&
                 e.InnerException.GetType() == typeof(Engine.Exceptions.UserFriendly)))
            {
                errorOutput.WriteLine(e.Message);
            }

            else
            {
                Path crashFile = EngineInstance.BuildCrashReport(e);


                // If we were able to build a crash report, display the exception and the report's location

                if (crashFile != null)
                {
                    errorOutput.WriteLine(e.Message);
                    errorOutput.WriteLine("(" + e.GetType() + ")");
                    errorOutput.WriteLine();
                    errorOutput.Write(Locale.SafeGet("NaturalDocs.CLI", "Crash.ReportAt(file).multiline",
                                                     "A crash report has been generated at {0}.\n" +
                                                     "Please include this file when asking for help at naturaldocs.org.\n", crashFile));
                }


                // If we couldn't build the crash report, display the information on the screen.

                else
                {
                    errorOutput.Write(EngineInstance.GetCrashInformation(e));
                    errorOutput.WriteLine();
                    errorOutput.WriteLine(Locale.SafeGet("NaturalDocs.CLI", "Crash.IncludeInfoAndGetHelp",
                                                         "Please include this information when asking for help at naturaldocs.org."));
                }


                // Include a notice for outdated Mono versions

                if (Engine.SystemInfo.MonoVersionTooOld)
                {
                    errorOutput.WriteLine();
                    errorOutput.WriteLine(Locale.SafeGet("NaturalDocs.Engine", "CrashReport.OutdatedMono(currentVersion, minimumVersion)",
                                                         "You appear to be using Mono {0}, which is very outdated.  This has been known to cause Natural Docs to crash.  Please update it to version {1} or higher.",
                                                         Engine.SystemInfo.MonoVersion, Engine.SystemInfo.MinimumMonoVersion));
                }
            }

            errorOutput.Write("------------------------------------------------------------\n\n");
        }