SCOrchDev-Exception
2.2.1
Used for wrapping and handling custom exceptions.
This is designed to make good error handling routines for enterprise automation like what is written for SMA.
Using this library you can make routines (like below) that behave consistantly in PowerShell and PowerShell worfklow.
The module also has functions for throwing meaningful errors to any PowerShell stream o
This is designed to make good error handling routines for enterprise automation like what is written for SMA.
Using this library you can make routines (like below) that behave consistantly in PowerShell and PowerShell worfklow.
The module also has functions for throwing meaningful errors to any PowerShell stream o
Used for wrapping and handling custom exceptions.
This is designed to make good error handling routines for enterprise automation like what is written for SMA.
Using this library you can make routines (like below) that behave consistantly in PowerShell and PowerShell worfklow.
The module also has functions for throwing meaningful errors to any PowerShell stream or converting an exception to a
string for usage in other functions.
Example:
Function Test-Throw-Function
{
try
{
Throw-Exception -Type 'CustomTypeA' `
-Message 'MessageA' `
-Property @{
'a' = 'b'
}
}
catch
{
$Exception = $_
$ExceptionInfo = Get-ExceptionInfo -Exception $Exception
Switch -CaseSensitive ($ExceptionInfo.Type)
{
'CustomTypeA'
{
Write-Exception -Exception $Exception -Stream Verbose
$a = $_
}
Default
{
Write-Warning -Message 'unhandled' -WarningAction Continue
}
}
}
}
Workflow Test-Throw-Workflow
{
try
{
Throw-Exception -Type 'CustomTypeA' `
-Message 'MessageA' `
-Property @{
'a' = 'b'
}
}
catch
{
$Exception = $_
$ExceptionInfo = Get-ExceptionInfo -Exception $Exception
Switch -CaseSensitive ($ExceptionInfo.Type)
{
'CustomTypeA'
{
Write-Exception -Exception $Exception -Stream Verbose
$a = $_
}
Default
{
Write-Warning -Message 'unhandled' -WarningAction Continue
}
}
}
}
Show more
This is designed to make good error handling routines for enterprise automation like what is written for SMA.
Using this library you can make routines (like below) that behave consistantly in PowerShell and PowerShell worfklow.
The module also has functions for throwing meaningful errors to any PowerShell stream or converting an exception to a
string for usage in other functions.
Example:
Function Test-Throw-Function
{
try
{
Throw-Exception -Type 'CustomTypeA' `
-Message 'MessageA' `
-Property @{
'a' = 'b'
}
}
catch
{
$Exception = $_
$ExceptionInfo = Get-ExceptionInfo -Exception $Exception
Switch -CaseSensitive ($ExceptionInfo.Type)
{
'CustomTypeA'
{
Write-Exception -Exception $Exception -Stream Verbose
$a = $_
}
Default
{
Write-Warning -Message 'unhandled' -WarningAction Continue
}
}
}
}
Workflow Test-Throw-Workflow
{
try
{
Throw-Exception -Type 'CustomTypeA' `
-Message 'MessageA' `
-Property @{
'a' = 'b'
}
}
catch
{
$Exception = $_
$ExceptionInfo = Get-ExceptionInfo -Exception $Exception
Switch -CaseSensitive ($ExceptionInfo.Type)
{
'CustomTypeA'
{
Write-Exception -Exception $Exception -Stream Verbose
$a = $_
}
Default
{
Write-Warning -Message 'unhandled' -WarningAction Continue
}
}
}
}
Minimum PowerShell version
4.0
Installation Options
Owners
Copyright
(c) SCOrchDev. All rights reserved.
Package Details
Author(s)
- Ryan Andorfer
Functions
Convert-ExceptionToString Get-ExceptionInfo New-Exception Select-CustomException Select-RelevantException Throw-Exception Write-Exception New-ThrownException
Dependencies
This module has no dependencies.
FileList
- SCOrchDev-Exception.nuspec
- LICENSE
- README.md
- SCOrchDev-Exception.psd1
- SCOrchDev-Exception.psm1
- SCOrchDev-Exception.tests.ps1