Skip to content
ConsoleMonster
Class

ExceptionView

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Implements
IWidget
Modifiers
sealed

An exception or PowerShell error, readable: the fail symbol and the type, the message, the PowerShell category, error id and position message, the script stack, the .NET frames as "Type.Method()" with shortened paths and file:line as links, framework frames collapsed into "+n framework frames", and the inner errors as "Caused by".

Inheritance

  • object
  • ExceptionView

Usage

Explore 32 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 16

Constructors

ExceptionView 2 overloads
public ExceptionView(ExceptionInfo info) #

Creates the view of an error description.

Parameters

info ConsoleMonster.Widgets.ExceptionInfo required
The description.
public ExceptionView(Exception exception) #

Creates the view of a .NET exception.

Parameters

exception System.Exception required
The exception.

Methods

public List<StyledLine> Lines(int width, RenderContext context) #

The lines of the view at a width.

Parameters

width int required
The width.
context ConsoleMonster.Canvas.RenderContext required
The render context.

Returns

List<StyledLine> The lines.
public Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.
public static string ShortMethod(string method) #

"Namespace.Type.Method(args)" as "Type.Method(args)"; script frames are left as they are.

Parameters

method string required
The method.

Returns

string The short form.
public string ShortPath(string path) #

A path relative to ExceptionView.BasePath when under it, otherwise the folder and file name.

Parameters

path string required
The path.

Returns

string The short path.

Properties

public bool Compact { get; set; } #

Uses a message-first layout with the invocation line and a folded inner-exception count.

public string? DetailsHint { get; set; } #

A muted next-step hint, or null for no hint.

public bool ShowFrameworkFrames { get; set; } #

Shows framework frames instead of collapsing them.

public int MaxFrames { get; set; } #

The most app frames shown per error (default 8); the rest are counted.

public bool ShowStack { get; set; } #

Shows the stack frames (default true); off shows the type, message and position only.

public int MaxInner { get; set; } #

How many inner errors are shown (default 4).

public bool ShowSource { get; set; } #

Shows the source lines around the first app frame whose file can be read (default true), highlighted.

public string? BasePath { get; set; } #

The folder paths are shown relative to (default the current directory).

Extension Methods

public static ExceptionView BasePath(ExceptionView exceptionView, string? value) #

Sets ExceptionView.BasePath: The folder paths are shown relative to (default the current directory).

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value string? required
The value.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property      // C# fluent
exceptionView.BasePath = value;    exceptionView.BasePath(value);
public static ExceptionView Compact(ExceptionView exceptionView, bool value = true) #

Sets ExceptionView.Compact: Uses a message-first layout with the invocation line and a folded inner-exception count.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property     // C# fluent
exceptionView.Compact = value;    exceptionView.Compact(value);
public static ExceptionView DetailsHint(ExceptionView exceptionView, string? value) #

Sets ExceptionView.DetailsHint: A muted next-step hint, or null for no hint.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value string? required
The value.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property         // C# fluent
exceptionView.DetailsHint = value;    exceptionView.DetailsHint(value);
public static ExceptionView MaxFrames(ExceptionView exceptionView, int value) #

Sets ExceptionView.MaxFrames: The most app frames shown per error (default 8); the rest are counted.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value int required
The value.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property       // C# fluent
exceptionView.MaxFrames = value;    exceptionView.MaxFrames(value);
public static ExceptionView MaxInner(ExceptionView exceptionView, int value) #

Sets ExceptionView.MaxInner: How many inner errors are shown (default 4).

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value int required
The value.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property      // C# fluent
exceptionView.MaxInner = value;    exceptionView.MaxInner(value);
public static ExceptionView ShowFrameworkFrames(ExceptionView exceptionView, bool value = true) #

Sets ExceptionView.ShowFrameworkFrames: Shows framework frames instead of collapsing them.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property                 // C# fluent
exceptionView.ShowFrameworkFrames = value;    exceptionView.ShowFrameworkFrames(value);
public static ExceptionView ShowSource(ExceptionView exceptionView, bool value = true) #

Sets ExceptionView.ShowSource: Shows the source lines around the first app frame whose file can be read (default true), highlighted.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property        // C# fluent
exceptionView.ShowSource = value;    exceptionView.ShowSource(value);
public static ExceptionView ShowStack(ExceptionView exceptionView, bool value = true) #

Sets ExceptionView.ShowStack: Shows the stack frames (default true); off shows the type, message and position only.

Parameters

exceptionView ConsoleMonster.Widgets.ExceptionView required
The instance.
value bool = true optional
The value; true when omitted.

Returns

ExceptionView The same instance.

Examples

// C# initializer or property       // C# fluent
exceptionView.ShowStack = value;    exceptionView.ShowStack(value);