[C++-sig] Exception Handling - What class is thrown?

Clay Culver clay at idleengineer.net
Wed Feb 23 02:40:08 CET 2005


I'm trying to handle exceptions that occur within an embedded script.  
Here's the code I'm basing this off of:

try
{
    // This will fail.
    handle<>(PyRun_String(
        "not_a_variable",
        Py_file_input, pyNamespace.ptr(), pyNamespace.ptr()
        )).reset();
}
catch (...)
{
    PyErr_Clear( );
}

That fails since not_a_variable hasn't been defined yet.  What I'd like 
to do is catch the exception and report the problem to the user.  The 
information about the error I can get using the Python/C api, but I 
can't figure out what class is actually being thrown so that I can 
replace the (...) with the actual class.  What is this class?

I've also been digging around the Boost.Python documentation, and I see 
a lot of information about converting exceptions, but I can't seem to 
find where the exceptions thrown by Boost.Python are documented.  Are 
those contained in one place?

Thanks!
Clay



More information about the Cplusplus-sig mailing list