GetDscResourceModuleConflict.cs (1904B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="GetDscResourceModuleConflict.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.Management.Configuration.Processor.Exceptions 8 { 9 using System; 10 using System.Management.Automation; 11 using Microsoft.PowerShell.Commands; 12 13 /// <summary> 14 /// A call to Get-DscResource failed because at least two modules with the same version where found in the module path. 15 /// If you are getting this verify the module path. 16 /// </summary> 17 internal class GetDscResourceModuleConflict : Exception 18 { 19 /// <summary> 20 /// Initializes a new instance of the <see cref="GetDscResourceModuleConflict"/> class. 21 /// </summary> 22 /// <param name="resourceName">Resource name.</param> 23 /// <param name="module">Optional module.</param> 24 /// <param name="inner">The original runtime exception thrown.</param> 25 public GetDscResourceModuleConflict(string? resourceName, ModuleSpecification? module, RuntimeException inner) 26 : base($"Multiple modules with same version in module path: {resourceName?.ToString() ?? "<no resource>"} [{module?.ToString() ?? "<no module>"}]", inner) 27 { 28 this.HResult = ErrorCodes.WinGetConfigUnitModuleConflict; 29 this.ResourceName = resourceName; 30 this.Module = module; 31 } 32 33 /// <summary> 34 /// Gets the resource name. 35 /// </summary> 36 public string? ResourceName { get; } 37 38 /// <summary> 39 /// Gets the module, if any. 40 /// </summary> 41 public ModuleSpecification? Module { get; } 42 } 43 }