Format-ConsoleError
Shows errors and exceptions readably: type, message, position, script stack, frames and inner errors.
Syntax
Format-ConsoleError [-AsWidget] [[-InputObject] <Object>] [-MaxFrames <Int32>] [-NoStack] [-ShowFrameworkFrames] [-Width <Int32>] [<CommonParameters>]#All Parameter SetsDescription
Shows errors and exceptions readably: type, message, position, script stack, frames and inner errors.
Takes ErrorRecords (from $Error, $_ in a catch block, -ErrorVariable) and .NET exceptions from the pipeline. Each shows the type and the message, the category and error id, PowerShell's position message with the failing line, the script stack, the .NET frames as Type.Method() with shortened paths and file:line links, framework frames collapsed into "+n framework frames", and the inner exceptions as "Caused by". With -AsWidget the views are returned for New-ConsolePanel, dashboards or Export-ConsoleFrame instead of written. Redirected output is plain text.
Examples
EXAMPLE 1
Format-ConsoleError -AsWidgetParameters
- -AsWidget SwitchParameter
- Returns the views instead of writing them.
- -InputObject Object
- An ErrorRecord, an exception or a message (pipeline input).
- -MaxFrames Int32
- The most app frames shown per error (default 8).
- -NoStack SwitchParameter
- Leaves out the stack frames: type, message and position only.
- -ShowFrameworkFrames SwitchParameter
- Shows framework frames (System, Microsoft, the PowerShell engine) instead of collapsing them.
- -Width Int32
- Lays the output out for this width instead of the terminal's.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.