You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$document= {
Get-DscResource TestStub |Import-DscResource
TestStub a @{
Key='a'ThrowOnSet='always'
}
}
Describe 'resource stack trace' {
$h=@{}
It 'create instructions' {
$h.Instructions= ConfigInstructions Name $document
}
foreach ( $stepin$h.Instructions )
{
It $step.Message {
$step|Invoke-ConfigStep
}
}
}
outputs
Describing resource stack trace
[+] create instructions 14.46s
[+] Pretest: Test resource [TestStub]a 1.28s
[-] Configure: Set resource [TestStub]a 162ms
RuntimeException: TestStub forced exception because ThrowOnSet=always
at Set-TargetResource<Process>, C:\Users\un1\Documents\WindowsPowerShell\Modu
les\ZeroDSC\DSCResources\TestStub\TestStub.psm1: line 56
at Invoke-MofResourceCommand<Process>, C:\Users\un1\Documents\WindowsPowerShe
ll\Modules\ZeroDSC\Functions\mofResourceInvokerType.ps1: line 105
at _Invoke, C:\Users\un1\Documents\WindowsPowerShell\Modules\ZeroDSC\Function
s\mofResourceInvokerType.ps1: line 21
at Invoke-ResourceCommand<Process>, C:\Users\un1\Documents\WindowsPowerShell\
Modules\ZeroDSC\Functions\resourceInvokerType.ps1: line 88
at Invoke, C:\Users\un1\Documents\WindowsPowerShell\Modules\ZeroDSC\Functions
\resourceInvokerType.ps1: line 33
at Invoke, C:\Users\un1\Documents\WindowsPowerShell\Modules\ZeroDSC\Functions
\boundResourceType.ps1: line 14
at <ScriptBlock>, C:\Users\un1\Documents\WindowsPowerShell\Modules\ZeroDSC\Fu
nctions\configInstructionsType.ps1: line 285
at Invoke-ConfigStep<Process>, C:\Users\un1\Documents\WindowsPowerShell\Modul
es\ZeroDSC\Functions\configInstructionsType.ps1: line 335
at <ScriptBlock>, <No file>: line 19
[+] Configure: Test resource [TestStub]a 320ms
Most of those lines are uninformative because they are just a record of the stack unwinding inside the ZeroDSC module. They should probably be omitted from the stack trace so that Pester shows only the helpful lines.
The text was updated successfully, but these errors were encountered:
Rewrite the .ScriptStackTrace property with a string that omits a bunch of the stack trace.
Catch the exception at lowest point in the call stack that is inside ZeroDSC, and somehow re-throw that same exception at the highest point in the call stack.
Change the way [ConfigStep] objects are set up such that the call stack between Invoke-ConfigStep and the underlying resource is minimized.
It doesn't seem like (2) would work because .ScriptStackTrace is populated when the exception is first thrown. So catching and re-throwing doesn't change its contents. For example,
Describing delayed re-throw
[-] test 18ms
RuntimeException: exception in f1
at f1, C:\Users\un1\Desktop\test.ps1: line 1
at f2, C:\Users\un1\Desktop\test.ps1: line 2
at f3, C:\Users\un1\Desktop\test.ps1: line 3
at f4, C:\Users\un1\Desktop\test.ps1: line 4
at <ScriptBlock>, C:\Users\un1\Desktop\test.ps1: line 8
This code
outputs
Most of those lines are uninformative because they are just a record of the stack unwinding inside the ZeroDSC module. They should probably be omitted from the stack trace so that Pester shows only the helpful lines.
The text was updated successfully, but these errors were encountered: