catch (std::exception &e){ // Prints any pending python exception with traceback // Might not do anything useful if SWIG already processed it. // Output goes to standard error, so you'll probably need to // have the server running in a console window - I doubt the // error will be reflected over telnet. We could mess with // redirection but that's non-trivial, and doesn't provide // that big of a benefit here. if(PyErr_Occured()) PyErr_Print(); // Assuming the exception derived from the standard C++ base // exception class std::exception, and that it has been // properly constructed, we try and report the exception data. c.DoAction( "error", 0, 0, 0, 0, e.what() ); return;}
You may need to include stdexcept to get the definition for std::exception and Python.h for the python stuff. I just hope Ron or the Python folks derived their exceptions from std::exception...
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan
[edited by - Fruny on May 19, 2004 10:42:27 AM]