Re: [Boost-bugs] [Boost C++ Libraries] #2781: Add python exception info extractor

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2781: Add python exception info extractor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-26 22:40:52


#2781: Add python exception info extractor
--------------------------+-------------------------------------------------
 Reporter: macke@… | Owner: dave
     Type: Patches | Status: new
Milestone: Boost 1.39.0 | Component: Python
  Version: Boost 1.38.0 | Severity: Not Applicable
 Keywords: |
--------------------------+-------------------------------------------------

Comment(by sohail-boost-trac@…):

 For me, it would be most useful if I could register an exception handling
 callback which allows me to throw my own exception when an error occurs in
 Python. This way, Python code can be called from C++ code just as if it is
 C++ code. Otherwise, we need to have boilerplate try/catch.

 For example, I'd like to write:
 {{{
 void my_from_python_exception_handler()
 {
   throw MyException(pyerror_exctract<My::String>()); // don't hardcode
 above extract to std::string
 }
 void
 somewhere_in_the_app()
 {
 ...
 boost::python::register_from_python_exception_handler(my_from_python_exception_handler);
 }

 void somewhere_else_in_the_app()
 {
   cplusplus->call_python_code_directly_but_looks_like_cplusplus();
 }
 }}}

 Hope that helps.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2781#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC