示例#1
0
 public string WriteNormalizedException(Exception ex, ExceptionFormats formats = ExceptionFormats.Default)
 {
     this.WriteException(ex, formats);
     return(string.Join("\n", Output.NormalizeStackTrace()
                        .NormalizeLineEndings()
                        .Split(new char[] { '\n' })
                        .Select(line => line.TrimEnd())));
 }
示例#2
0
        public string[] WriteExceptionAndGetLines(Exception ex, ExceptionFormats formats = ExceptionFormats.Default)
        {
            this.WriteException(ex, formats);

            return(Output.NormalizeStackTrace()
                   .NormalizeLineEndings()
                   .Split(new char[] { '\n' })
                   .Select(line => line.TrimEnd())
                   .ToArray());
        }
示例#3
0
        /// <summary>
        /// Gets a <see cref="IRenderable"/> representation of the exception.
        /// </summary>
        /// <param name="exception">The exception to format.</param>
        /// <param name="format">The exception format options.</param>
        /// <returns>A <see cref="IRenderable"/> representing the exception.</returns>
        public static IRenderable GetRenderable(this Exception exception, ExceptionFormats format = ExceptionFormats.Default)
        {
            if (exception is null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            return(GetRenderable(exception, new ExceptionSettings
            {
                Format = format,
            }));
        }
 /// <summary>
 /// Writes an exception to the console.
 /// </summary>
 /// <param name="console">The console.</param>
 /// <param name="exception">The exception to write to the console.</param>
 /// <param name="format">The exception format options.</param>
 public static void WriteException(this IAnsiConsole console, Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 {
     console.Write(exception.GetRenderable(format));
 }
 /// <summary>
 /// Writes an exception to the console.
 /// </summary>
 /// <param name="exception">The exception to write to the console.</param>
 /// <param name="format">The exception format options.</param>
 public static void WriteException(Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 {
     Console.WriteException(exception, format);
 }
        public static string WriteNormalizedException(this TestConsole console, Exception ex, ExceptionFormats formats = ExceptionFormats.Default)
        {
            if (!string.IsNullOrWhiteSpace(console.Output))
            {
                throw new InvalidOperationException("Output buffer is not empty.");
            }

            console.WriteException(ex, formats);
            return(string.Join("\n", NormalizeStackTrace(console.Output)
                               .NormalizeLineEndings()
                               .Split(new char[] { '\n' })
                               .Select(line => line.TrimEnd())));
        }