#include "stl_container_adapter.hpp"
-void translate(IndexError const& e)
+#include <boost/python/exception_translator.hpp>
+using namespace boost::python;
+
+void translate_index_error(IndexError const& e)
{
PyErr_SetString(PyExc_IndexError, "Index out of range");
}
-void translate(KeyError const& e)
+void translate_key_error(KeyError const& e)
{
PyErr_SetString(PyExc_KeyError, "Key not found");
}
+void export_container_exceptions()
+{
+ boost::python::register_exception_translator<IndexError>(
+ &translate_index_error
+ );
+
+ boost::python::register_exception_translator<KeyError>(
+ &translate_key_error
+ );
+}