[IronPython] is it possible to raise a System.Web.Exception from IronPython?

Richard Nienaber rjnienaber at gmail.com
Wed Dec 29 14:37:35 CET 2010


>  Is there any way tocatch this exception from IronPython

I'm not sure if there's a corresponding python exception but you can
definitely catch the WebException:

C#:
using System.Net;

public class RaiseException {
    public void Raise() { throw new WebException("My Exception"); }
}

IronPython 2.6/2.7:

import clr
from System.Net import WebException
clr.AddReference("RaiseException")
import RaiseException
o = RaiseException()
try:
    o.Raise()
except WebException, e:
    print e.Message     #prints 'My Exception'

On Wed, Dec 29, 2010 at 1:07 PM, Pablo Dalmazzo <pablodalma93 at hotmail.com>wrote:

>  Sorry guys, I didnt mean to raise, I wanted to say TO CATCH
>
> ------------------------------
> From: pablodalma93 at hotmail.com
> To: users at lists.ironpython.com
> Date: Wed, 29 Dec 2010 10:05:07 -0300
> Subject: [IronPython] is it possible to raise a System.Web.Exception from
> IronPython?
>
>
> Hi there,
>
> I was reading Michael's book for exception handling and in the book he says
> when a .NET exception percolates through to IronPython, it’s wrapped as a
> Python exception, and that you can catch a lot of .NET exceptions using the
> equivalent Python exceptions, and he gives a link where there are listed
> .net exception and their equivalents Python exceptions.
> But  System.Web.Exception isnt there. Is there any way to
> catch this exception from IronPython or a workaround?
>
> Greetings, Pablo
>
>
>
> _______________________________________________ Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20101229/71906eda/attachment.html>


More information about the Ironpython-users mailing list