projects
/
mussa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
translate KeyError too
[mussa.git]
/
py
/
stl_container_adapter.cpp
diff --git
a/py/stl_container_adapter.cpp
b/py/stl_container_adapter.cpp
index 5135b44288a81255532f30f6d8e66fca17dc1b90..ab1ab36d48a3321dc7f8624e36cfa781b5478483 100644
(file)
--- a/
py/stl_container_adapter.cpp
+++ b/
py/stl_container_adapter.cpp
@@
-1,12
+1,25
@@
#include "stl_container_adapter.hpp"
#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");
}
{
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");
}
{
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
+ );
+}