So if you have code like the following:

cdef class Database:
    cdef open(self, path) except +raise_py_error:
        something_that_can_throw_a_cpp_exception(path)

you can write

cdef int raise_py_error():
    raise Something

to kind of turn a C++ exception into a Python exception.  The problem appears
to be that you cannot include in the Python exception any information
contained in the C++ exception, because there's no access to the C++ exception
that was thrown.

The generated code does a `catch(...)` so you lose that useful information.
AFAICT, there's no way to find out within the catch clause (or anything called
by that clause) what C++ exception occurred.

It would sure be useful if raise_py_error() was passed the exception instance
that was caught.  Then at least our handler could extract some useful
information to relay to the Python level.  E.g. in the case above, it might
tell us that the `path` is nonexistent.

Cheers,
-Barry

Attachment: signature.asc
Description: PGP signature

_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to