Powershell: Get-Date -UFormat ''は、空の文字列引数に対して役に立たない例外をスローします

作成日 2017年10月07日  ·  3コメント  ·  ソース: PowerShell/PowerShell

Get-Date -UFormat ''の空の文字列引数は、$#$ 1 IndexOutOfRangeException #$をスローします。エラーが何が間違っているかを示し、UFormat引数に注意を向けた場合に役立ちます。 「UFormat文字列がないか無効です」またはその効果のある単語。

再現する手順

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

Area-Cmdlets-Utility Hacktoberfest Resolution-Fixed Up-for-Grabs

最も参考になるコメント

これに取り組みます。

全てのコメント3件

同意します。すべてのエラーメッセージは、ユーザーが実行可能である必要があります(または、不可能な場合は情報を提供します)。

これに取り組みます。

@DdWrこれをつかんでくれてありがとう。 通常、初心者はほとんどのスタイルのコメントを受け取ります。 コーディングガイドラインをお読みください。 主に、周囲のコードのスタイルに従う必要があります。 また、テストを追加してください(ShouldBeErrorId関数を使用してください)。 新しいエラーメッセージを適切なResxファイルに入れます。

このページは役に立ちましたか?
0 / 5 - 0 評価