API Reference
ExceptionInfo
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
- Method ExceptionInfo.FromException
- Property ExceptionInfo.Inner
Accepted by parameters 1
- Constructor ExceptionView.ExceptionView
Constructors
public ExceptionInfo(String type, String message) #Creates an error description.
Parameters
- type System.String
- The type name (short or full).
- message System.String
- The message.
Methods
public static ExceptionInfo FromException(Exception exception, Int32 depth = 8) #ExceptionInfoDescribes a .NET exception and its inner exceptions (aggregate exceptions follow their first inner).
Parameters
- exception System.Exception
- The exception.
- depth System.Int32 = 8
- How many inner exceptions to follow (default 8).
Returns
The description.
public static Boolean IsFrameworkMethod(String method) #BooleanWhether a method belongs to the framework (System, Microsoft, the PowerShell engine) rather than the app.
Parameters
- method System.String
- The method as the stack trace names it.
Returns
True for framework frames.
public static List<ExceptionFrame> ParseScriptStackTrace(String? scriptStackTrace) #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?
- The script stack trace text, or null.
Returns
The frames.
public static List<ExceptionFrame> ParseStackTrace(String? stackTrace) #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?
- The stack trace text, or null.
Returns
The frames.
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
Properties
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.