Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
Last active December 28, 2015 19:03
Show Gist options
  • Save trondhindenes/a1d72085d9c727bd8910 to your computer and use it in GitHub Desktop.
Save trondhindenes/a1d72085d9c727bd8910 to your computer and use it in GitHub Desktop.
ErrorWeirdness
Function Inner
{
[CmdletBinding()]
Param ()
Try
{
throw "Inner exception"
}
Catch
{
Return $null
}
Return "yep"
}
Function Outer
{
[CmdletBinding()]
Param ()
Try
{
$a = Inner -ErrorAction Stop -ErrorVariable "innerErr"
}
Catch
{
}
if ($a -eq $null)
{
Write-Error "An error occurred"
}
}
Outer -ErrorAction SilentlyContinue -ErrorVariable myvar
$myvar
@alx9r
Copy link

alx9r commented Dec 28, 2015

That is truly bizarre behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment