Functions/GenXdev.Windows/Show-ExceptionPanel.ps1
|
<############################################################################## Part of PowerShell module : GenXdev.Windows Original cmdlet filename : Show-ExceptionPanel.ps1 Original author : René Vaessen / GenXdev Version : 3.29.2026 ################################################################################ Copyright (c) 2026 René Vaessen / GenXdev Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ################################################################################> <# .SYNOPSIS Shows an exception in a nice panel using Spectre.Console .DESCRIPTION Uses Spectre.Console to show an exception in a nice panel. .PARAMETER Exception Exception object to show in the panel. .EXAMPLE try { throw "This is a test exception" } catch { Show-ExceptionPanel -Exception $_.Exception } #> function Show-ExceptionPanel { param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = "The exception to show in the panel.")] [System.Exception] $Exception ) $AnsiConsole = [Spectre.Console.AnsiConsole] $ExceptionFormats = [Spectre.Console.ExceptionFormats] # Write the exception using Spectre's built-in formatting $AnsiConsole::WriteException( $Exception, $ExceptionFormats::ShortenEverything -bor $ExceptionFormats::ShowLinks ) } |