Skip to content
ConsoleMonster

API Reference

Class

ExceptionInfo

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Modifiers sealed

What ExceptionView shows of an error: the type, the message, the stack frames, the inner error and, for PowerShell errors, the category, the error id, the script stack and the position message. Built from a .NET exception with ExceptionInfo.FromException, or filled in by a host (the PowerShell module maps ErrorRecords).

Inheritance

  • Object
  • ExceptionInfo

Usage

Explore 3 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.

Returned or exposed by 2

Accepted by parameters 1

Constructors

public ExceptionInfo(String type, String message) #

Creates an error description.

Parameters

type System.String requiredposition: 0
The type name (short or full).
message System.String requiredposition: 1
The message.

Methods

public static ExceptionInfo FromException(Exception exception, Int32 depth = 8) #
Returns: ExceptionInfo

Describes a .NET exception and its inner exceptions (aggregate exceptions follow their first inner).

Parameters

exception System.Exception requiredposition: 0
The exception.
depth System.Int32 = 8 optionalposition: 1
How many inner exceptions to follow (default 8).

Returns

The description.

public static Boolean IsFrameworkMethod(String method) #
Returns: Boolean

Whether a method belongs to the framework (System, Microsoft, the PowerShell engine) rather than the app.

Parameters

method System.String requiredposition: 0
The method as the stack trace names it.

Returns

True for framework frames.

public static List<ExceptionFrame> ParseScriptStackTrace(String? scriptStackTrace) #
Returns: List<ExceptionFrame>

Parses a PowerShell script stack trace ("at Get-Thing, C:\x.ps1: line 12", "at <ScriptBlock>, <No file>: line 1").

Parameters

scriptStackTrace System.String? requiredposition: 0
The script stack trace text, or null.

Returns

The frames.

public static List<ExceptionFrame> ParseStackTrace(String? stackTrace) #
Returns: List<ExceptionFrame>

Parses a .NET stack trace ("at Type.Method(args) in C:\file.cs:line 42", one frame per line).

Parameters

stackTrace System.String? requiredposition: 0
The stack trace text, or null.

Returns

The frames.

Properties

public String Type { get; } #

The type name.

public String Message { get; } #

The message.

public List<ExceptionFrame> Frames { get; } #

The .NET stack frames, innermost call first, as the runtime lists them.

public List<ExceptionFrame> ScriptFrames { get; } #

The PowerShell script stack (commands and script lines), or empty.

public String? PositionMessage { get; set; } #

The PowerShell position message ("At C:\x.ps1:12 char:5" with the line and the marker), or null.

public String? Category { get; set; } #

The PowerShell category and reason, for example "ObjectNotFound (C:\missing:String)", or null.

public String? ErrorId { get; set; } #

The PowerShell error id, for example "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand", or null.

public ExceptionInfo? Inner { get; set; } #

The error that caused this one, or null.