using System; using Spectre.Console.Internal; using Spectre.Console.Rendering; namespace Spectre.Console { /// /// Contains extension methods for . /// public static class ExceptionExtensions { /// /// Gets a representation of the exception. /// /// The exception to format. /// The exception format options. /// A representing the exception. 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, }); } /// /// Gets a representation of the exception. /// /// The exception to format. /// The exception settings. /// A representing the exception. public static IRenderable GetRenderable(this Exception exception, ExceptionSettings settings) { if (exception is null) { throw new ArgumentNullException(nameof(exception)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } return ExceptionFormatter.Format(exception, settings); } } }