Skip to content

Commit de7df1a

Browse files
committed
Improve error messages
1 parent e0e6489 commit de7df1a

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ body:
1818
description: "What versions are affected? Versions must be listed as supported in the Security Policy (/.github/SECURITY.md)."
1919
multiple: true
2020
options:
21+
- "v0.4.1"
2122
- "v0.4.0"
2223
- "v0.3.4"
2324
- "v0.3.3"

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RootModule = 'hugoalh.GitHubActionsToolkit.psm1'
44

55
# Version number of this module.
6-
ModuleVersion = '0.4.0'
6+
ModuleVersion = '0.4.1'
77

88
# Supported PSEditions
99
# CompatiblePSEditions = @()

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psm1

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function Write-GitHubActionsCommand {
5858
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_write-githubactionscommand#Write-GitHubActionsCommand')]
5959
[OutputType([void])]
6060
param (
61-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'GitHub Actions command must be in single line string!')][string]$Command,
61+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Command` must be in single line string!')][string]$Command,
6262
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)][Alias('Content')][string]$Message = '',
6363
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)][Alias('Properties')][hashtable]$Property = @{}
6464
)
@@ -94,7 +94,7 @@ function Add-GitHubActionsEnvironmentVariable {
9494
param(
9595
[Parameter(Mandatory = $true, ParameterSetName = 'multiple', Position = 0, ValueFromPipeline = $true)][Alias('Input', 'Object')][hashtable]$InputObject,
9696
[Parameter(Mandatory = $true, ParameterSetName = 'single', Position = 0, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not match the require environment variable name pattern!')][Alias('Key')][string]$Name,
97-
[Parameter(Mandatory = $true, ParameterSetName = 'single', Position = 1, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'Environment variable value must be in single line string!')][string]$Value
97+
[Parameter(Mandatory = $true, ParameterSetName = 'single', Position = 1, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Value` must be in single line string!')][string]$Value
9898
)
9999
begin {
100100
[hashtable]$Result = @{}
@@ -104,13 +104,13 @@ function Add-GitHubActionsEnvironmentVariable {
104104
'multiple' {
105105
$InputObject.GetEnumerator() | ForEach-Object -Process {
106106
if ($_.Name.GetType().Name -ne 'string') {
107-
Write-Error -Message 'Environment variable name must be type of string!' -Category 'InvalidType'
107+
Write-Error -Message 'Parameter `Name` must be type of string!' -Category 'InvalidType'
108108
} elseif ($_.Name -notmatch '^(?:[\da-z][\da-z_-]*)?[\da-z]$') {
109109
Write-Error -Message "``$($_.Name)`` is not match the require environment variable name pattern!" -Category 'SyntaxError'
110110
} elseif ($_.Value.GetType().Name -ne 'string') {
111-
Write-Error -Message 'Environment variable value must be type of string!' -Category 'InvalidType'
111+
Write-Error -Message 'Parameter `Value` must be type of string!' -Category 'InvalidType'
112112
} elseif ($_.Value -notmatch '^.+$') {
113-
Write-Error -Message 'Environment variable value must be in single line string!' -Category 'SyntaxError'
113+
Write-Error -Message 'Parameter `Value` must be in single line string!' -Category 'SyntaxError'
114114
} else {
115115
$Result[$_.Name] = $_.Value
116116
}
@@ -153,7 +153,7 @@ function Add-GitHubActionsPATH {
153153
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_add-githubactionspath#Add-GitHubActionsPATH')]
154154
[OutputType([void])]
155155
param(
156-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'PATH must be in single line string!')][Alias('Paths')][string[]]$Path,
156+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Path` must be in single line string!')][Alias('Paths')][string[]]$Path,
157157
[Alias('NoValidate', 'SkipValidate', 'SkipValidator')][switch]$NoValidator
158158
)
159159
begin {
@@ -195,8 +195,8 @@ function Add-GitHubActionsProblemMatcher {
195195
[CmdletBinding(DefaultParameterSetName = 'path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_add-githubactionsproblemmatcher#Add-GitHubActionsProblemMatcher')]
196196
[OutputType([void])]
197197
param (
198-
[Parameter(Mandatory = $true, ParameterSetName = 'path', Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][SupportsWildcards()][ValidatePattern('^.+$', ErrorMessage = 'GitHub Actions problem matcher path must be in single line string!')][Alias('File', 'Files', 'Paths')][string[]]$Path,
199-
[Parameter(Mandatory = $true, ParameterSetName = 'literal-path', ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'GitHub Actions problem matcher literal path must be in single line string!')][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][string[]]$LiteralPath
198+
[Parameter(Mandatory = $true, ParameterSetName = 'path', Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][SupportsWildcards()][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Path` must be in single line string!')][Alias('File', 'Files', 'Paths')][string[]]$Path,
199+
[Parameter(Mandatory = $true, ParameterSetName = 'literal-path', ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `LiteralPath` must be in single line string!')][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][string[]]$LiteralPath
200200
)
201201
begin {}
202202
process {
@@ -373,7 +373,7 @@ function Disable-GitHubActionsProcessingCommands {
373373
'set-output',
374374
'warning'
375375
))
376-
}, ErrorMessage = 'GitHub Actions disable processing commands end token must be in single line string, more than or equal to 4 characters, not match any GitHub Actions commands, and unique!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][string]$EndToken = ((New-Guid).Guid -replace '-', '')
376+
}, ErrorMessage = 'Parameter `EndToken` must be in single line string, more than or equal to 4 characters, not match any GitHub Actions commands, and unique!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][string]$EndToken = ((New-Guid).Guid -replace '-', '')
377377
)
378378
Write-GitHubActionsCommand -Command 'stop-commands' -Message $EndToken
379379
return $EndToken
@@ -483,7 +483,7 @@ function Enable-GitHubActionsProcessingCommands {
483483
'set-output',
484484
'warning'
485485
))
486-
}, ErrorMessage = 'GitHub Actions enable processing commands end token must be in single line string, more than or equal to 4 characters, and not match any GitHub Actions commands!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][string]$EndToken
486+
}, ErrorMessage = 'Parameter `EndToken` must be in single line string, more than or equal to 4 characters, and not match any GitHub Actions commands!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][string]$EndToken
487487
)
488488
return Write-GitHubActionsCommand -Command $EndToken
489489
}
@@ -532,7 +532,7 @@ function Enter-GitHubActionsLogGroup {
532532
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_enter-githubactionsloggroup#Enter-GitHubActionsLogGroup')]
533533
[OutputType([void])]
534534
param(
535-
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$', ErrorMessage = 'GitHub Actions log group title must be in single line string!')][Alias('Header', 'Message')][string]$Title
535+
[Parameter(Mandatory = $true, Position = 0)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header', 'Message')][string]$Title
536536
)
537537
return Write-GitHubActionsCommand -Command 'group' -Message $Title
538538
}
@@ -880,7 +880,7 @@ function Remove-GitHubActionsProblemMatcher {
880880
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_remove-githubactionsproblemmatcher#Remove-GitHubActionsProblemMatcher')]
881881
[OutputType([void])]
882882
param (
883-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][ValidatePattern('^.+$', ErrorMessage = 'GitHub Actions problem matcher owner must be in single line string!')][Alias('Identifies', 'Identify', 'Identifier', 'Identifiers', 'Key', 'Keys', 'Name', 'Names', 'Owners')][string[]]$Owner
883+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Owner` must be in single line string!')][Alias('Identifies', 'Identify', 'Identifier', 'Identifiers', 'Key', 'Keys', 'Name', 'Names', 'Owners')][string[]]$Owner
884884
)
885885
begin {}
886886
process {
@@ -936,11 +936,11 @@ function Set-GitHubActionsOutput {
936936
'multiple' {
937937
$InputObject.GetEnumerator() | ForEach-Object -Process {
938938
if ($_.Name.GetType().Name -ne 'string') {
939-
Write-Error -Message 'GitHub Actions output name must be type of string!' -Category InvalidType
939+
Write-Error -Message 'Parameter `Name` must be type of string!' -Category InvalidType
940940
} elseif ($_.Name -notmatch '^(?:[\da-z][\da-z_-]*)?[\da-z]$') {
941941
Write-Error -Message "``$($_.Name)`` is not match the require GitHub Actions output name pattern!" -Category SyntaxError
942942
} elseif ($_.Value.GetType().Name -ne 'string') {
943-
Write-Error -Message 'GitHub Actions output value must be type of string!' -Category InvalidType
943+
Write-Error -Message 'Parameter `Value` must be type of string!' -Category InvalidType
944944
} else {
945945
Write-GitHubActionsCommand -Command 'set-output' -Message $_.Value -Property @{ 'name' = $_.Name }
946946
}
@@ -986,11 +986,11 @@ function Set-GitHubActionsState {
986986
'multiple' {
987987
$InputObject.GetEnumerator() | ForEach-Object -Process {
988988
if ($_.Name.GetType().Name -ne 'string') {
989-
Write-Error -Message 'GitHub Actions state name must be type of string!' -Category InvalidType
989+
Write-Error -Message 'Parameter `Name` must be type of string!' -Category InvalidType
990990
} elseif ($_.Name -notmatch '^(?:[\da-z][\da-z_-]*)?[\da-z]$') {
991991
Write-Error -Message "``$($_.Name)`` is not match the require GitHub Actions state name pattern!" -Category SyntaxError
992992
} elseif ($_.Value.GetType().Name -ne 'string') {
993-
Write-Error -Message 'GitHub Actions state value must be type of string!' -Category InvalidType
993+
Write-Error -Message 'Parameter `Value` must be type of string!' -Category InvalidType
994994
} else {
995995
Write-GitHubActionsCommand -Command 'save-state' -Message $_.Value -Property @{ 'name' = $_.Name }
996996
}
@@ -1130,12 +1130,12 @@ function Write-GitHubActionsAnnotation {
11301130
param (
11311131
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][GitHubActionsAnnotationType]$Type,
11321132
[Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true)][Alias('Content')][string]$Message,
1133-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions annotation issue file must be in single line string!')][Alias('Path')][string]$File,
1133+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `File` must be in single line string!')][Alias('Path')][string]$File,
11341134
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineStart', 'StartLine')][uint]$Line,
11351135
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][uint]$Column,
11361136
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineEnd')][uint]$EndLine,
11371137
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('ColEnd', 'ColumnEnd', 'EndCol')][uint]$EndColumn,
1138-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions annotation title must be in single line string!')][Alias('Header')][string]$Title
1138+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][string]$Title
11391139
)
11401140
begin {}
11411141
process {
@@ -1232,12 +1232,12 @@ function Write-GitHubActionsError {
12321232
[OutputType([void])]
12331233
param (
12341234
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][Alias('Content')][string]$Message,
1235-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions error annotation issue file must be in single line string!')][Alias('Path')][string]$File,
1235+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `File` must be in single line string!')][Alias('Path')][string]$File,
12361236
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineStart', 'StartLine')][uint]$Line,
12371237
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][uint]$Column,
12381238
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineEnd')][uint]$EndLine,
12391239
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('ColEnd', 'ColumnEnd', 'EndCol')][uint]$EndColumn,
1240-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions error annotation title must be in single line string!')][Alias('Header')][string]$Title
1240+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][string]$Title
12411241
)
12421242
begin {}
12431243
process {
@@ -1275,12 +1275,12 @@ function Write-GitHubActionsFail {
12751275
[OutputType([void])]
12761276
param(
12771277
[Parameter(Mandatory = $true, Position = 0)][Alias('Content')][string]$Message,
1278-
[ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions error annotation issue file must be in single line string!')][Alias('Path')][string]$File,
1278+
[ValidatePattern('^.*$', ErrorMessage = 'Parameter `File` must be in single line string!')][Alias('Path')][string]$File,
12791279
[Alias('LineStart', 'StartLine')][uint]$Line,
12801280
[Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][uint]$Column,
12811281
[Alias('LineEnd')][uint]$EndLine,
12821282
[Alias('ColEnd', 'ColumnEnd', 'EndCol')][uint]$EndColumn,
1283-
[ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions error annotation title must be in single line string!')][Alias('Header')][string]$Title
1283+
[ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][string]$Title
12841284
)
12851285
Write-GitHubActionsAnnotation -Type 'Error' -Message $Message -File $File -Line $Line -Column $Column -EndLine $EndLine -EndColumn $EndColumn -Title $Title
12861286
exit 1
@@ -1313,12 +1313,12 @@ function Write-GitHubActionsNotice {
13131313
[OutputType([void])]
13141314
param (
13151315
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][Alias('Content')][string]$Message,
1316-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions notice annotation issue file must be in single line string!')][Alias('Path')][string]$File,
1316+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `File` must be in single line string!')][Alias('Path')][string]$File,
13171317
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineStart', 'StartLine')][uint]$Line,
13181318
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][uint]$Column,
13191319
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineEnd')][uint]$EndLine,
13201320
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('ColEnd', 'ColumnEnd', 'EndCol')][uint]$EndColumn,
1321-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions notice annotation title must be in single line string!')][Alias('Header')][string]$Title
1321+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][string]$Title
13221322
)
13231323
begin {}
13241324
process {
@@ -1358,12 +1358,12 @@ function Write-GitHubActionsWarning {
13581358
[OutputType([void])]
13591359
param (
13601360
[Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)][Alias('Content')][string]$Message,
1361-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions warning annotation issue file must be in single line string!')][Alias('Path')][string]$File,
1361+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `File` must be in single line string!')][Alias('Path')][string]$File,
13621362
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineStart', 'StartLine')][uint]$Line,
13631363
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('Col', 'ColStart', 'ColumnStart', 'StartCol', 'StartColumn')][uint]$Column,
13641364
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('LineEnd')][uint]$EndLine,
13651365
[Parameter(ValueFromPipelineByPropertyName = $true)][Alias('ColEnd', 'ColumnEnd', 'EndCol')][uint]$EndColumn,
1366-
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'GitHub Actions warning annotation title must be in single line string!')][Alias('Header')][string]$Title
1366+
[Parameter(ValueFromPipelineByPropertyName = $true)][ValidatePattern('^.*$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][string]$Title
13671367
)
13681368
begin {}
13691369
process {

0 commit comments

Comments
 (0)