I am trying to write something similar to this:
function Do-Something () {
Write-Host "Starting something"
Do-SomethingWhichThrowsAnException
Write-Host "Something completed successfully"
}
...
function Process-Thing () {
try {
Do-OneThing
Do-TwoThing
Do-Something
Do-SomethingElse
}
catch {
Write-Host "Exception Caught!"
}
}
And I get the following output:
Starting something
{massive red exception text}
Something completed successfully
Why do I not see "Exception Caught!"?
Why do I see "Something completed successfully"?
Does Powershell simply not throw exceptions up the stack or something?
If so, is it possible to slap it into submission? Do I have to try/catch inside every one of my Do-XXXthing
functions?