dsccommunity / dsccommunity/SChannelDsc
Replace throw with New-InvalidOperationException in DSC_SChannelSettings
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 13
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Description
Replace the raw throw statement in DSC_SChannelSettings.psm1 (lines 599-600) with New-InvalidOperationException using a localized message.
Changes Needed
-
Add a new localized string key to
source/DSCResources/DSC_SChannelSettings/en-US/DSC_SChannelSettings.strings.psd1:HotfixNotInstalled = 'Hotfix KB3140245 is not installed. Setting these registry keys will not do anything. Please install the hotfix first.' -
Replace the throw statement in
source/DSCResources/DSC_SChannelSettings/DSC_SChannelSettings.psm1(lines 599-600):# Current: throw ('Hotfix KB3140245 is not installed. Setting these registry keys will not do anything. ' + ` 'Please install the hotfix first!') # Should be: New-InvalidOperationException -Message $script:localizedData.HotfixNotInstalled
Context
MOF-based DSC resources must use New-InvalidOperationException instead of raw throw statements for proper error handling, and all user-facing strings must be localized.
References
- PR #66: https://github.com/dsccommunity/SChannelDsc/pull/66
- Comment: https://github.com/dsccommunity/SChannelDsc/pull/66#discussion_r2732718715
- Requested by: @johlju
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read source/DSCResources/DSC_SChannelSettings/DSC_SChannelSettings.psm1 around lines 599-600 and the localized strings in source/DSCResources/DSC_SChannelSettings/en-US/DSC_SChannelSettings.strings.psd1. Add the HotfixNotInstalled message to the strings file and replace the raw throw with New-InvalidOperationException using the localized value. Done means the error uses the localized message and the resource no longer contains this raw throw.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- devops
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100