Ok. So I wrote a simple boost python application. I put the exception handling code in. Now, as a test, I tried to run (purposely) a python script with a syntax error in it. The application crashes each time (Runtime Error!). How can I change the app so that it handles python script syntax errors without crashing?
monstro
0
Newbie Poster
Recommended Answers
Jump to PostCould you give us the offending code and the Traceback? Your explanation is devoid of any information that could allow us to help you.
Help US help you!
Jump to PostMay be you could try this
catch (...) { if(PyErr_Occurred()) { PyErr_Print(); boost::python::object traceback(boost::python::handle<>(PyImport_ImportModule("traceback"))); std::string err_text = boost::python::extract<std::string>(traceback.attr("format_exc")()); logErrors = "Exception caught: "; logErrors += err_text; LogMessage((char*)logErrors.c_str()); boost::python::handle_exception(); } success = false; }
I don't think the
sys.stderr.getvalue
exists :)
All 6 Replies
jlm699
320
Veteran Poster
monstro
0
Newbie Poster
monstro
0
Newbie Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
monstro
0
Newbie Poster
monstro
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.