Error messages do not include useful source information

37 views
Skip to first unread message

Roman Kuzmin

unread,
Aug 10, 2011, 1:03:52 AM8/10/11
to psake-dev
Error messages do not include source information, the most important
piece.

Compare:

psake message:
The term 'Test1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or
if a path was included,
verify that the path is correct and try again.

classic message:
The term 'Test1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or
if a path was included,
verify that the path is correct and try again.
At C:\TEMP\default.ps1:5 char:7
+ Test1 <<<<
+ CategoryInfo : ObjectNotFound: (Test1:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Classic error messages show the source and even point to the piece of
line with an error.

I know about
$config.verboseError = 1

, tried this and did not really find it useful. It is verbose too
much, all I want is to see the file name and the line number. In
verbose messages it takes too long to find this information.

I would propose to change the line:
$error_message = "{0}: An Error Occurred: `n{1}" -f (Get-
Date), $_
To
$error_message = "{0}: An Error Occurred: `n{1}" -f (Get-
Date), ($_ | Out-String)

This change makes error source shown in messages.

Alternatively, there might be more levels of verbosity, that is:

$config.verboseError = 0 # just like now, very brief error message
$config.verboseError = 1 # like I propose with source information
$config.verboseError = 2 # like it is verbose now.

Roman Kuzmin

unread,
Aug 11, 2011, 8:32:59 AM8/11/11
to psake-dev
I have submitted the pull request:
https://github.com/JamesKovacs/psake/pull/20
Reply all
Reply to author
Forward
0 new messages