-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add '-Reset' switch parameter to Test-PSFFunctionInterrupt (or add additional function) #606
Comments
You are totally right, that for this kind of flow we need a reset capability. |
Mentioning the |
Nope, sorry.
That's a builtin Parameter that comes with all commands.
Damn, that should not have happened of course. Anyway, I think the reset capability I'll include in the next release should address your issue. |
Not working at all or just misunderstood. Example function: function Invoke-MyScript {
[CmdletBinding()]
param (
[scriptblock]$ScriptBlock,
[string]$LoggingAction
)
Invoke-PSFProtectedCommand -Action $LoggingAction -ScriptBlock $ScriptBlock -Level host
Write-PSFMessage -Level Critical "Accessing the error, Variant 1: $_"
Write-PSFMessage -Level Critical "Accessing the error, Variant 2: $($Error[0]|Out-String)"
Write-PSFMessage -Level Critical "Accessing the error, Variant 3: $(Get-Error|Out-String)"
}
$invokeCommandParam = @{
scriptBlock = [scriptblock]::Create("`$result = 1 / 0")
LoggingAction = "Will Fail"
}
invoke-MyScript @invokeCommandParam Executed I see as a result
Runspace Anomaly?The solution only works if I call the function from the same context, e.g. if I put the above code in a PS1 file and execute it. In my real life scenario the function is provided by a module (based on Cost some time to find the cause lies (partly) in providing the function in the module.... |
Alright, I messed up a little with the error event: function Invoke-MyScript {
[CmdletBinding()]
param (
[scriptblock]$ScriptBlock,
[string]$LoggingAction
)
Invoke-PSFProtectedCommand -Action $LoggingAction -ScriptBlock $ScriptBlock -Level host -ErrorEvent {
Write-PSFMessage -Level Critical "Accessing the error, Variant 1: $($args[0])"
}
}
$invokeCommandParam = @{
scriptBlock = [scriptblock]::Create("`$result = 1 / 0")
LoggingAction = "Will Fail"
}
invoke-MyScript @invokeCommandParam Supporting And no, PSFramework does not expect you to define the scriptblock you run with |
While using the FlowControl functions I often stumble over the following problem: I'm using Invoke-PSFProtectedCommand to often 😄
simple dummy code:
Scenario is that
throw
to trigger the retry countTest-PSFFunctionInterrupt
registers that the checks have failed andProblem is that the second
Test-PSFFunctionInterrupt
returns $true and the complete function stops. It would be great if you could provide a function/parameter to clean the$psframework_killqueue
.The text was updated successfully, but these errors were encountered: