How to know the line of an error?

76 views
Skip to first unread message

jobou

unread,
May 27, 2010, 11:27:30 PM5/27/10
to psake-users

when I have an error the message does not indicate on which line it's
throw ...

it's always tell you that the error is from the root build file and
it's not ...

default.ps1:The Windows PowerShell snap-in
'sqlserverprovidersnapin100' is not installed on this machine.

Dustin Venegas

unread,
May 28, 2010, 11:47:31 AM5/28/10
to psake...@googlegroups.com
For a quick answer, you can turn on PSake error logging. Just modify the PSake.ps1 file. After the import-module, you can set logging with the following command:
  $PSake.log_error = $true.
This will dump out a psake-error-log-{date}.log file after a run that you can inspect.

Long term wise, is there any objection to PSake Write-Hosting the detailed on error?


--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To post to this group, send email to psake...@googlegroups.com.
To unsubscribe from this group, send email to psake-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.




--
Dustin Eric Venegas
Dustin....@gmail.com

Jason Jarrett

unread,
May 28, 2010, 11:52:39 AM5/28/10
to psake...@googlegroups.com
+1 on displaying as much as possible when an error happens...

Jorge

unread,
May 30, 2010, 3:59:41 PM5/30/10
to psake-users
Jason,

I have no objection to dumping out to the console the same information
that is logged to the error log file - that's an easy change but it
would impact everyone who uses psake so I'd like to hear more from
everyone before that kind of change is made.

On May 28, 10:52 am, Jason Jarrett <sta...@gmail.com> wrote:
> +1 on displaying as much as possible when an error happens...
>
> On Fri, May 28, 2010 at 8:47 AM, Dustin Venegas <dustin.vene...@gmail.com>wrote:
>
> > For a quick answer, you can turn on PSake error logging. Just modify the
> > PSake.ps1 file. After the import-module, you can set logging with the
> > following command:
> >   $PSake.log_error = $true.
> > This will dump out a psake-error-log-{date}.log file after a run that you
> > can inspect.
>
> > Long term wise, is there any objection to PSake Write-Hosting the detailed
> > on error?
>
> > On Thu, May 27, 2010 at 10:27 PM, jobou <jonatanbouil...@gmail.com> wrote:
>
> >> when I have an error the message does not indicate on which line it's
> >> throw ...
>
> >> it's always tell you that the error is from the root build file and
> >> it's not ...
>
> >> default.ps1:The Windows PowerShell snap-in
> >> 'sqlserverprovidersnapin100' is not installed on this machine.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "psake-users" group.
> >> To post to this group, send email to psake...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> psake-users...@googlegroups.com<psake-users%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/psake-users?hl=en.
>
> > --
> > Dustin Eric Venegas
> > Dustin.Vene...@gmail.com
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "psake-users" group.
> > To post to this group, send email to psake...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > psake-users...@googlegroups.com<psake-users%2Bunsu...@googlegroups.com>
> > .

Jonathan Matheus

unread,
May 30, 2010, 7:16:45 PM5/30/10
to psake...@googlegroups.com
How does psake handle the -verbose common parameter? I think that
dumping that information in verbose mode would be acceptable. I'm
always a fan of "more info is better" when it comes to errors.

Dusty Candland

unread,
May 31, 2010, 10:48:42 AM5/31/10
to psake...@googlegroups.com
+1 for verbose option


Dusty

Jorge Matos

unread,
May 31, 2010, 3:42:56 PM5/31/10
to psake...@googlegroups.com
I think the problem is a little harder then we all thought - if you look at the output of the psake error log file you will notice that even though you get more information - the exact line and column position of the error in the build script isn't correct - that's because psake is dot-sourcing the build file and not parsing it - so that means the error line is actually the line in the psake module where the error was detected - it will always be the line number for the Assert() function which is by psake to test for and throw errors.

Below is an example of the error log file when I ran: Invoke-psake .\specs\default_task_with_action_should_fail.ps1

Notice the ScriptLineNumber has a value of 399 - that's the line number in the psake.psml not the line number in .\specs\default_task_with_action_should_fail.ps1 

This may be a tough nut to crack.

----------------------------------------------------------------------
5/31/2010 2:26:35 PM: An Error Occurred. See Error Details Below:
----------------------------------------------------------------------
ErrorRecord
PSMessageDetails      :
Exception             : System.Management.Automation.RuntimeException: Error: 'default' task cannot specify an action
TargetObject          : Error: 'default' task cannot specify an action
CategoryInfo          : OperationStopped: (Error: 'default...ecify an action:String) [], RuntimeException
FullyQualifiedErrorId : Error: 'default' task cannot specify an action
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {}

ErrorRecord.InvocationInfo
MyCommand        :
BoundParameters  : {}
UnboundArguments : {}
ScriptLineNumber : 399
OffsetInLine     : 10
HistoryId        : 183
ScriptName       : C:\Users\Jorge\Documents\Projects\psake\psake.psm1
Line             :     throw $failureMessage
PositionMessage  :
                   At C:\Users\Joge\Documents\Projects\psake\psake.psm1:399 char:10
                   +     throw <<<<  $failureMessage
InvocationName   : throw
PipelineLength   : 0
PipelinePosition : 0
ExpectingInput   : False
CommandOrigin    : Internal

Exception
0000000000000000000000000000000000000000000000000000000000000000000000
ErrorRecord                 : Error: 'default' task cannot specify an action
StackTrace                  :
WasThrownFromThrowStatement : True
Message                     : Error: 'default' task cannot specify an action
Data                        : {}
InnerException              :
TargetSite                  :
HelpLink                    :
Source                      :

Jorge

unread,
Jun 2, 2010, 8:58:11 PM6/2/10
to psake-users
One odd thought I had maybe to introduce a "parse" step to the build.
Before dot-sourcing the build file we first parse the file and report
any syntax errors.

Thoughts?

Dustin Venegas

unread,
Jun 3, 2010, 9:53:08 PM6/3/10
to psake...@googlegroups.com
I've actually been able to get a pretty good estimation of the error location from the psake-error-log and haven't noticed the line numbers issue.

I believe the correct line numbers are displayed if there is an actual syntax error in the file. I think it's just the local errors that occur once the script is running that output shifted line numbers.

--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To post to this group, send email to psake...@googlegroups.com.
To unsubscribe from this group, send email to psake-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.




--
Dustin Eric Venegas
Dustin....@gmail.com

Jorge Matos

unread,
Jun 7, 2010, 9:34:11 PM6/7/10
to psake...@googlegroups.com
It doesn't appear that anyone is complaining about the line number - so I'm not going to worry about it.

Reply all
Reply to author
Forward
0 new messages