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

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Wed Feb 23 09:28:33 CET 2005


If you look at the tutorial here :

http://www.boost.org/libs/python/doc/tutorial/doc/html/python/embedding.html

You'll read that the exception thrown is "error_already_set".
For further details about the Python exception you'll need to use the 
CPython functions.

Pierre

Clay Culver a écrit :
> 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
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68



More information about the Cplusplus-sig mailing list