Open konstantinvlasenko opened 9 years ago
Hmm, I tried to use $Lastexitcode and $?. Unfortunately, It does not recognize errors like Get-Service invalidservice. AFAIK, it is very hard or impossible to redirect error stream only to PS variable without temporal file. Maybe you have other ideas?
@2xmax I didn't get how Get-Service invalidservice relates to this issue? I, believe, in you example the exception were handled internally by underlying code of Get-Service. And what you seen in the console output is just the result of Write-Host. I think nothing can be done here. But again, it is not about the issue we are trying to discuss :)
I think the main issue is that we have removed this ELSE https://github.com/konstantinvlasenko/PowerSlim/pull/71/files#diff-3a586a9b299992da7ba63a2496a138f2L312 for non-terminating error. We should just return the error as the result of the script execution. But not as SLIM exception. What do you think?
The main problem with previous version was concerned with skipping such statements: |eval|$somevar=Get-XXXFeature| where Get-XXXFeature write some very important info in std error (that is actually visible in powershell console). My idea was to highlight such test yellow.
(if I understood you right, powerslim will not show the error if we just return it as result of script execution)
It will if you will use |check| or |show|
Maybe we should introduce a global setting?! $NonTerminatingIsException = $true In this case we'll use your new approach. What do you think?
It will if you will use |check| or |show|
I remember several times I received such test reports: |eval|...something..may not broke..| # but it broken for unpredictable moment, and the result of this was very interesting |check|eval|Get-XXXFeature|...| it comes out I created |PS| scenario that executed |show|eval|@script|, then I modified slim.ps1 and got rid of |PS| scenario.
BTW, not only me used this |PS| scenario:)
So what we are going to do? I don't want to Test-Path before calling Remove-Item.
I think the $NonTerminatingIsException = $true should be enough for your case. You can always set it to TRUE. But by default it should be FALSE.
NonTerminatingIsException flag is ok for me. I agree with you, It can be painful if there are already a lot if rmdir and remove-items in suite.
remove-items is just one example :) It can be Remove-SPWeb or DELETE method for any REST API for non-existing object. Basically we are talking about any cleanup operation. I don't want to check the existence of something before removing it. Can you make this change?
ok, will do
https://github.com/konstantinvlasenko/PowerSlim/blob/master/FitNesseRoot/PowerSlim/OriginalMode/SuiteCommon/TestCatchException/content.txt