SharePoint 2010
developers love Powershell. It really is a huge step forward. If you still haven't started to use it, do so.
But I got bit the
other day, when I added a try-catch block to my code.
See if you can spot
it:
Try
{
$legen = Create-Object
Reidar.Husmo.AwesomeClass
$legen.Dary(42)
}
Catch
{
"an error occurred"
}
As you no doubt
immediately spotted, Powershell does not have a Create-Object. But the
try-catch hides coding mistakes. There is no indication that things are not ok,
not even "an error occurred" is returned.
If you examine the $Error object, you'll see that things are not ok, but that's not how we're used to look for errors.