Wrapper for exception translation
Hi everyone, for my current project I was in need for a simple method to make user defined exceptions within my module. The basic framework in the form of exception translation is there so I only needed to make it a bit more accessible. I made a template function exception_<Exception> (const char *name) which creates a python exception and an instance of templated translation handler. The translation handler instance is held in the python translation's class dictionary as the __handler__ attribute. Then the handler is registered as an exception translator for the Exception using register_exception_translator(). The python exception object is finally registered in the current scope's dictionary using the "name" argument to exception_(). To register an exception translator for exception e you simply call exception_<e> ("e") within your module init function. This implementation is quite usable for me but I would be totally glad if it could somehow be integrated with pyste. I tested it with gcc-3.2, gcc-3.3 and gcc-2.95 Cheers, Gottfried
Gottfried.Ganssauge@HAUFE.DE writes:
for my current project I was in need for a simple method to make user defined exceptions within my module. The basic framework in the form of exception translation is there so I only needed to make it a bit more accessible. I made a template function exception_<Exception> (const char *name) which creates a python exception and an instance of templated translation handler. The translation handler instance is held in the python translation's class dictionary as the __handler__ attribute. Then the handler is registered as an exception translator for the Exception using register_exception_translator(). The python exception object is finally registered in the current scope's dictionary using the "name" argument to exception_().
To register an exception translator for exception e you simply call exception_<e> ("e") within your module init function.
This implementation is quite usable for me but I would be totally glad if it could somehow be integrated with pyste.
This looks like a question about integration with Boost.Python itself to me. Isn't it? Could you explain how your facility improves on what's already in the library? I'm sorry to be dense, but the answer's not jumping out at me. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams -
Gottfried.Ganssauge@HAUFE.DE