[Ironpython-users] Exception handling in VS 2008

Cash nokia1 at gmail.com
Sun Feb 5 14:05:57 CET 2012


I'm getting issues with try / except blocks in VS 2008, particularly with
the following way of catching the errors:



except Error as e:

    do something with e

When I try this directly from the IPY console it works fine:

>>> try:
...         open(fakefile.txt)
...     except NameError as e:
...         print 'E is: ' + `e`
E is: NameError("name 'fakefile' is not defined",)

When entering the same code into Visual Studio 2008, it doesn’t like the
syntax at all and highlights the 'as e' part as a syntax error.

Has anyone seen this before and know a way around it at all please? As it
works in the IPY console and is valid Python, I'm presuming it is a bug
within VS?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120205/5bacb5ab/attachment.html>

More information about the Ironpython-users mailing list