alx9r/ZeroDSC

ConfigInstructions should include location of offending line in exception for duplicate resources

Opened this issue · 0 comments

alx9r commented

Executing

ConfigInstructions Name {
    Get-DscResource TestStub | Import-DscResource
    Get-DscResource TestStub | Import-DscResource
    TestStub a @{ Key = 'a' }
}

raises the exception

Duplicate resource named TestStub
At C:\Users\un1\Documents\WindowsPowerShell\Modules\ZeroDSC\Functions\configDocumentType.ps1:94 char:17
+                 throw [System.FormatException]::new(
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FormatException
    + FullyQualifiedErrorId : Duplicate resource named TestStub

The file name and line number of the second Import-DscResource should be reported in the exception.

A test for this behavior is already mentioned in configDocumentType.Tests.ps1