Dino Viehland wrote:
Jeff wrote:
I'm trying to fix up the exceptions for the _sqlite3 module I'm
implementing. The dbapi spec (PEP 249) requires a very specific
exception hierarchy, including exceptions derived from StandardError.

My initial version just used C# Exception classes, but StandardError
is not a normal class, so that was insufficient. I looked into how the
existing modules did it (using PythonContext.EnsureModuleException)
and started to implement that but I've run up against a bit of a
roadblock: PythonExceptions.CreateThrowable is internal. It's not a
problem for anything in IronPython.Modules, of course, because of the
accursed InternalsVisibleToAttribute, but that doesn't help me much
:).

Is there a public way to create and throw a Python exception (i.e. a
BaseException instance)? For now I'm just using reflection, but I
would like a better way.

There's a public PythonOps.CreateThrowable.  It just forwards the call
to the internal PythonExceptions.CreateThrowable.

Speaking about exceptions. Is there a way to convert the System.Exception to the Python exception when I know the System.Exception is a Python exception?

I ran into this when I played with data binding and BindingValidationError event. This event is raised when a setter throws an exception. So I threw MyException. But in the event, the event.Error.Exception is System.Exception and I couldn't figured out how to access the Python properties in this "MyException".

--
-- Lukás(
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to