dsccommunity / dsccommunity/SChannelDsc

Replace throw with New-InvalidOperationException in DSC_SChannelSettings

Open
#68 0 comments 0 reactions 0 assignees View on GitHub

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

  1. 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.'
    
  2. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.