Um argumento de string vazio em Get-Date -UFormat ''
lança IndexOutOfRangeException
, seria mais útil se o erro dissesse o que estava errado e direcionasse a atenção para o argumento UFormat. "String UFormat ausente ou inválida" ou palavras nesse sentido.
PS /test> get-date -uformat "$accidentallyEmptyFormatStringVariable"
get-date : Index was outside the bounds of the array.
At line:1 char:1
+ get-date -uformat ''
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Date], IndexOutOfRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException,Microsoft.PowerShell.Commands.GetDateCommand
A message directing attention to the -UFormat string parameter being empty.
A message about some internal problem.
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta.8
PSEdition Core
GitCommitId v6.0.0-beta.8
OS Linux 2.6.32-042stab120.6 #1 SMP Thu Oct 27 16:59:03 MSK 2016
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Concordo, todas as mensagens de erro devem ser acionáveis pelo usuário (ou informativas, se não for possível)
Vou trabalhar neste.
@DdWr Obrigado por pegar isso. Normalmente, os iniciantes recebem a maioria dos comentários de estilo. Por favor, leia as Diretrizes de codificação . Principalmente você deve seguir o estilo do código ao redor. Adicione também um teste (use nossa função ShouldBeErrorId). Coloque a nova mensagem de erro no arquivo Resx apropriado.
Comentários muito úteis
Vou trabalhar neste.