mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-29 17:28:06 +01:00
Add support for rendering exceptions
This commit is contained in:
committed by
Patrik Svensson
parent
971f9032ba
commit
3c3afe7439
22
src/Spectre.Console/Extensions/ExceptionExtensions.cs
Normal file
22
src/Spectre.Console/Extensions/ExceptionExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains extension methods for <see cref="Exception"/>.
|
||||
/// </summary>
|
||||
public static class ExceptionExtensions
|
||||
{
|
||||
/// <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.None)
|
||||
{
|
||||
return ExceptionFormatter.Format(exception, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user