FindDscResourceNotFoundException.cs (1580B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="FindDscResourceNotFoundException.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 Microsoft.PowerShell.Commands; 11 12 /// <summary> 13 /// Resource not found by Find-DscResource. 14 /// </summary> 15 internal class FindDscResourceNotFoundException : Exception 16 { 17 /// <summary> 18 /// Initializes a new instance of the <see cref="FindDscResourceNotFoundException"/> class. 19 /// </summary> 20 /// <param name="resourceName">Resource name.</param> 21 /// <param name="module">Optional module.</param> 22 public FindDscResourceNotFoundException(string resourceName, ModuleSpecification? module) 23 : base($"Could not find resource: {resourceName} [{module?.ToString() ?? "<no module>"}]") 24 { 25 this.HResult = ErrorCodes.WinGetConfigUnitNotFoundRepository; 26 this.ResourceName = resourceName; 27 this.Module = module; 28 } 29 30 /// <summary> 31 /// Gets the resource name. 32 /// </summary> 33 public string ResourceName { get; } 34 35 /// <summary> 36 /// Gets the module, if any. 37 /// </summary> 38 public ModuleSpecification? Module { get; } 39 } 40 }