SCOrchDev-Exception

2.1.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 or co
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

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name SCOrchDev-Exception -RequiredVersion 2.1.1

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name SCOrchDev-Exception -Version 2.1.1

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) SCOrchDev. All rights reserved.

Package Details

FileList

Version History

Version Downloads Last updated
2.2.1 15,347 2/23/2016
2.2.0 368 12/21/2015
2.1.7 111 12/17/2015
2.1.1 (current version) 248 9/16/2015
2.1.0.1 72 9/14/2015
2.1.0.0 94 9/11/2015
Show more