Reputation: 2803
I need to throw an exception when a directory is not found and suppress the detail informations.
if( ! (Test-Path -Path $destDir) )
{
throw "Directory $destDir not found!"
}
In this case the message is shown and the details
, where it was thrown in the code.
Is there a way to show only the message without the details?
(I tested throw ... 2>$null
but that doesn't work)
Upvotes: 1
Views: 4618
Reputation: 43499
Use $_.Exception.Message
in your catch block. More information here.
Upvotes: 2