diff --git a/swig/tokenreader.i b/swig/tokenreader.i index 4a77779c0b7403a40834bf4ffeef00645e61a89e..522c6287c720c5f7d326f5a90cf841b3b7972461 100644 --- a/swig/tokenreader.i +++ b/swig/tokenreader.i @@ -7,6 +7,7 @@ #include <libcorpus2/io/helpers.h> %} +%include <exception.i> %include "tag.i" %include "token.i" %include "chunk.i" @@ -42,6 +43,10 @@ namespace Corpus2 { } catch (PwrNlp::PwrNlpError &e) { PyErr_SetString(PyExc_IndexError, e.info().c_str()); return NULL; + } catch (xmlpp::parse_error &e) { + std::string s("xmlpp::parse_error: "), s2(e.what()); + s = s + s2; + SWIG_exception(SWIG_RuntimeError, s.c_str()); } } %feature("autodoc", "1"); @@ -56,6 +61,10 @@ namespace Corpus2 { } catch (PwrNlp::PwrNlpError &e) { PyErr_SetString(PyExc_IndexError, e.info().c_str()); return NULL; + } catch (xmlpp::parse_error &e) { + std::string s("xmlpp::parse_error: "), s2(e.what()); + s = s + s2; + SWIG_exception(SWIG_RuntimeError, s.c_str()); } } %feature("autodoc", "1");