コード例 #1
0
        public static void ShowCriticalError(object exceptionObj, string message = null, string title = null)
        {
            const string defaultMessage = "Oh snap! Something went wrong.";

            if (message == null)
            {
                message = defaultMessage;
            }

            ConsoleHelpers.EnsureConsole();
            if (!string.IsNullOrEmpty(title))
            {
                Console.Title = title;
            }
            var    exception = exceptionObj as Exception;
            string msg;

            if (exception != null)
            {
                msg = $"{Environment.NewLine}[CRITICAL] {message}{Environment.NewLine}{Environment.NewLine}" +
                      $"{exception.Message}{Environment.NewLine}" +
                      $"{exception.StackTrace}";
            }
            else
            {
                msg = $"{Environment.NewLine}[CRITICAL] {message}{Environment.NewLine}{Environment.NewLine}" +
                      $"{exceptionObj}{Environment.NewLine}";
            }
            Console.Error.WriteLine(msg);
        }
コード例 #2
0
 public static void ShowCriticalInfo(string message, string title = null, bool suffixNewLine = true)
 {
     ConsoleHelpers.EnsureConsole();
     if (!string.IsNullOrEmpty(title))
     {
         Console.Title = title;
     }
     if (suffixNewLine)
     {
         Console.Error.WriteLine(message);
     }
     else
     {
         Console.Error.Write(message);
     }
 }