[Python.NET] catching exceptions thrown from .Net
Mathew Yeates
mathew at yeates.tv
Tue Jul 5 17:32:31 CEST 2005
yes, RC2. My bad.
Are we talking about the same thing? I noticed in the docs that you have
an example of throwing exceptions from within the python code. But no
examples of handling exceptions thrown within the .Net code.
Anyway ... theres not much to this code
.Net code
--------------------------------------------
public class MineralDBException:Exception
{
public MineralDBException(String msg):base(msg){
}
}
public MineralDBase(String fname)
{
try
{
fs = new FileStream(fname, FileMode.Open, FileAccess.Read);
}
catch(Exception e)
{
throw new MineralDBException(e.Message);
}
----------------------------------
python code, no exception is seen when calling MineralDBase this way but
an exception IS seen when calling from another .Net assembly
-----------------------------------
db=MineralDBase("fooey")
Mathew
Brian Lloyd wrote:
>Hmm, you mention RC5 -- do you mean RC2? An example code snippet would
>help here, as the unit tests actually use NullReferenceException and they
>are
>running fine for me...
>
>
>
>Brian Lloyd brian at zope.com
>V.P. Engineering 540.361.1716
>Zope Corporation http://www.zope.com
>
>
> -----Original Message-----
> From: Mathew Yeates [mailto:mathew at yeates.tv]
> Sent: Tuesday, July 05, 2005 9:41 AM
> To: Brian Lloyd
> Cc: pythondotnet at python.org
> Subject: Re: [Python.NET] catching exceptions thrown from .Net
>
>
> yes, it inherits from System.Exception. In fact, I tried throwing a
>NullRefernceException from my dll. Still nothing.
>
> Mathew
>
> Brian Lloyd wrote:
>Is this supposed to work in RC5 on Win32 using the supplied python
>binary? I have a .Net dll which throws a user defined exception but its
>being ignored by my python code.
>
>Is this to be expected?
>
>Mathew
>
>Does the user defined exception inherit (eventually) from
>System.Exception? If so, it should work...
>
>
>Brian Lloyd brian at zope.com
>V.P. Engineering 540.361.1716
>Zope Corporation http://www.zope.com
>
>
>
>
>
>
>
More information about the PythonDotNet
mailing list