Skip to content

Useful error message when HelpMessage attributes are empty string - #4334

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:helpmessage
Jul 26, 2017
Merged

Useful error message when HelpMessage attributes are empty string#4334
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:helpmessage

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

Fix invalid value error message on some cmdlet attributes to point to the specific attribute.

Removed wrapping of argument exception into not useful requires exception

Before:

.\helpmessage.ps1 : Cannot process the #requires statement because it is not in the correct format.
The #requires statement must be in one of the following formats:
 "#requires -shellid <shellID>"
 "#requires -version <major.minor>"
 "#requires -psedition <edition>"
 "#requires -pssnapin <psSnapInName> [-version <major.minor>]"
 "#requires -modules <ModuleSpecification>"
 "#requires -runasadministrator"
At line:1 char:1
+ .\helpmessage.ps1
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (helpmessage.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : ScriptRequiresInvalidFormat

After:

Cannot process argument because the value of argument "HelpMessage" is not valid. Change the value of the
"HelpMessage" argument and run the operation again.
At line:1 char:1
+ .\helpmessage.ps1
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : Argument

Fix #4331

… the specific attribute.

Removed wrapping of argument exception into not useful requires exception

@lzybkr Jason Shirk (lzybkr) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sign off assuming the #requires error message has not degraded from this change.

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) ScriptRequiresException still gets thrown in all other cases

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 0cd7a4a into PowerShell:master Jul 26, 2017
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the helpmessage branch July 26, 2017 16:28
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
… is set to empty string (PowerShell#4334)

- Fix invalid value error message on some properties of ParameterAttribute to point to the specific properties.
- Avoid wrapping argument exception into not a useful 'requires' exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants