Ahh, ok... Can you wrap the user code you run w/ more python code? If you
could then you could do:
try:
// run user code
except:
import sys
print sys.exc_info()[2].tb_lineno
print sys.exc_info()[2].tb_frame.f_code.co_filename
That's the Python way to get this information. Let us know if that seems to
burdensome. If so we could look at a way to expose this information via the
engine APIs instead of requiring you to create this wrapper.
Do you want to help develop Dynamic languages on CLR?
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alex Henderson
Sent: Monday, May 15, 2006 1:48 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Line numbers in snippets...
Not quite... my problem is I don't have a PythonSyntaxError thrown, I
believe that's because I'm actually receiving a python generated exception,
for instance I might catch a PythonNameError when someone incorrectly spells
a variable name... and that doesn't contain any information I can use the
locate where in the snippet string the error occurred... Is there a way to
get this information out of the PythonEngine itself perhaps?
The reason I ask that I just want to implement a feature where by a user can
look at a log "view" in our product, see an error has occurred in their
script, and be able to double click the entry and navigate to our code
editor and be on the right line for fixing the problem - for this to happen
we need to be able to extract some details of where the error occurred when
using PythonEngine.Execute...
Any ideas I would be greatly appreciated... :)
Chez,
- Alex
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:users-
> [EMAIL PROTECTED] On Behalf Of Dino Viehland
> Sent: Tuesday, 16 May 2006 8:21 a.m.
> To: Discussion of IronPython
> Subject: Re: [IronPython] Line numbers in snippets...
>
> We recently made a change so that PythonSyntaxError contains a Line,
> Column, Filename, and some other properties on it that you should be able
> to get at for this information. Is that what you're looking for?
>
>
> Do you want to help develop Dynamic languages on CLR?
> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-
> 11F0-45DF-8B78-DC1B43134038)
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:users-
> [EMAIL PROTECTED] On Behalf Of Alex Henderson
> Sent: Monday, May 15, 2006 1:09 PM
> To: 'Discussion of IronPython'
> Subject: [IronPython] Line numbers in snippets...
>
> We've been using IronPython as a scripting engine in one of our products
> that's in development for a while now, works great :)
>
> However when executing code which has syntax errors in it we can't seem to
> get line numbers back from the exception, or find any compilation context
> we
> can examine for a list of errors - which makes it difficult to diagnose
> problems obviously.
>
> I figure this is probably a limitation of the execute method, unless I've
> missed something... is there a different approach we could use where we
> will
> get line numbers when an error occurs?
>
> Chez,
>
> - Alex
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com