Created
June 18, 2020 04:46
-
-
Save krzydoug/749ca724a3adb26e07f8f0bf665ed1af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'stop' | |
Clear-Host | |
"============================================ Drivenotfoundexception =============================================" | |
try { | |
Get-Childit | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.Drivenotfoundexception] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildI | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.Drivenotfoundexception] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"================================================ Breakexception =================================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.BreakException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.BreakException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"=========================================== ParameterBindingException ============================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.ParameterBindingException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.ParameterBindingException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"========================================== ApplicationFailedException ===========================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.ApplicationFailedException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.ApplicationFailedException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"=========================================== Commandnotfoundexception ============================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.Commandnotfoundexception] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.Commandnotfoundexception] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"============================================== TerminateException ===============================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.TerminateException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.TerminateException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"============================================== SetValueException ================================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.SetValueException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.SetValueException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
$var1,$var2,$var3,$var4 = $null | |
"========================================== PSObjectDisposedException ============================================" | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
#<# | |
catch [System.Management.Automation.PSObjectDisposedException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var1 = $_ | |
$var3 = $error[0] | |
} | |
try { | |
Get-ChildItem -LiteralPath 'abcd:' -ErrorAction Stop | |
} | |
# remove the 1st "#" below to disable the 1st catch | |
<# | |
catch [System.Management.Automation.PSObjectDisposedException] | |
{ | |
} | |
#> | |
catch | |
{ | |
$var2 = $_ | |
$var4 = $error[0] | |
} | |
try | |
{ | |
'Compare $_' | |
Compare-Object -ReferenceObject $var1 -DifferenceObject $var2 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $_.invocationinfo' | |
Compare-Object -ReferenceObject $var1.InvocationInfo -DifferenceObject $var2.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0]' | |
Compare-Object -ReferenceObject $var3 -DifferenceObject $var4 | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} | |
'=' * 30 | |
try | |
{ | |
'Compare $error[0].invocationinfo' | |
Compare-Object -ReferenceObject $var3.InvocationInfo -DifferenceObject $var4.InvocationInfo | Out-Null | |
"good" | |
} | |
catch | |
{"something went wrong"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment