Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useful error message when HelpMessage attributes are empty string #4334

Merged
merged 1 commit into from Jul 26, 2017

Conversation

SteveL-MSFT
Copy link
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
Copy link
Member

@lzybkr lzybkr left a comment

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
Member Author

@lzybkr ScriptRequiresException still gets thrown in all other cases

@daxian-dbw daxian-dbw merged commit 0cd7a4a into PowerShell:master Jul 26, 2017
@SteveL-MSFT SteveL-MSFT deleted the helpmessage branch July 26, 2017 16:28
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.

None yet

5 participants