Hello, All!
I try to execute the next code:
class Foo
{
.....
Static [int] method1()
{
$res = [Foo]::method2()
....
return 0
}
Static [int] method2()
{
try
{
......
return 0
}
catch
{
Write-Error "Error: $_"
return 1
}
}
}
When I try to call one method from another method of Class with error handling, I can’t get the error message.
If I change Write-Error to Write-Host - all works fine, and method shows the error message.
What’s the right way of using of Write-Error in Class Methods ?