Skip to content

Replace throw with New-InvalidOperationException in DSC_SChannelSettings #68

@coderabbitai

Description

@coderabbitai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions