Skip to content

Commit

Permalink
Add spectre exception custom format demo and fix docs update script
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Jan 4, 2025
1 parent 7437f8c commit a65ee6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
5 changes: 0 additions & 5 deletions PwshSpectreConsole.Docs/src/powershell/UpdateDocs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ if($Branch -eq "prerelease") {
$astroConfig = $astroConfig -replace 'title: "PwshSpectreConsole"', 'title: "PwshSpectreConsole (Pre-release)"'
$astroConfig = $astroConfig -replace 'https://pwshspectreconsole.com', 'https://prerelease.pwshspectreconsole.com'
Set-Content -Path $astroConfigPath -Value $astroConfig

$astroSitemapConfig = "$PSScriptRoot\..\..\public\robots.txt"
$astroSitemap = Get-Content -Path $astroSitemapConfig -Raw
$astroSitemap = $astroSitemap -replace 'https://pwshspectreconsole.com', 'https://prerelease.pwshspectreconsole.com'
Set-Content -Path $astroSitemapConfig -Value $astroSitemap
}

if($NoBuild) {
Expand Down
23 changes: 22 additions & 1 deletion PwshSpectreConsole/public/formatting/Format-SpectreException.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,33 @@ The style to use when rendering the exception provided as a hashtable. e.g.
```
.EXAMPLE
# **Example 1** # This example demonstrates how to format an exception into a Spectre Console Exception with syntax highlighting.
# **Example 1**
# This example demonstrates how to format an exception into a Spectre Console Exception with syntax highlighting.
try {
Get-ChildItem -BadParam -ErrorAction Stop
} catch {
$_ | Format-SpectreException -ExceptionFormat ShortenEverything
}
.EXAMPLE
# **Example 2**
# This example uses custom formatting for the exception.
try {
Get-ChildItem -BadParam -ErrorAction Stop
} catch {
$_ | Format-SpectreException -ExceptionStyle @{
Message = "#00ff00"
Exception = "white"
Method = "#ff0000 on orange1"
ParameterType = "blue"
ParameterName = "silver"
Parenthesis = "silver"
Path = "Yellow"
LineNumber = "blue"
Dimmed = "grey"
NonEmphasized = "silver"
}
}
#>
function Format-SpectreException {
[Reflection.AssemblyMetadata("title", "Format-SpectreException")]
Expand Down

0 comments on commit a65ee6c

Please sign in to comment.