Skip to content

Instantly share code, notes, and snippets.

@Jaykul
Created May 6, 2015 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaykul/3db6f1553500350a9f69 to your computer and use it in GitHub Desktop.
Save Jaykul/3db6f1553500350a9f69 to your computer and use it in GitHub Desktop.
Exceptions and Errors
[324]: try {
· try{
· throw [System.Management.Automation.ParameterBindingException]::new( "whatever",
· [System.Management.Automation.ItemNotFoundException]::new("File Not Found"))
· } catch{ throw $_}
· } catch [System.Management.Automation.ParameterBindingException] { "PBE" }
· catch [System.Management.Automation.ItemNotFoundException] { "INFE" }
PBE
[325]:
· try {
· try{
· throw [System.Management.Automation.ParameterBindingException]::new( "whatever",
· [System.Management.Automation.ItemNotFoundException]::new("File Not Found"))
· } catch [System.Management.Automation.ParameterBindingException] { "PBE1" }
· catch [System.Management.Automation.ItemNotFoundException] { "INFE1"; throw $_ }
· catch { Write-Host "Rethrow Anyway"; throw }
· } catch [System.Management.Automation.ParameterBindingException] { "PBE2" }
· catch [System.Management.Automation.ItemNotFoundException] { "INFE2" }
INFE1
INFE2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment