diff --git a/swig/libcorpustagsetmanager.i b/swig/libcorpustagsetmanager.i index d0d7f0889e57d745c864d3dff440e8fcda926d68..adc0b4c9aa55c8310043c97e3ab6d248c1b8eaac 100644 --- a/swig/libcorpustagsetmanager.i +++ b/swig/libcorpustagsetmanager.i @@ -41,6 +41,18 @@ namespace Corpus2 { /* --------------------------------------------------------------------- */ }; + + %exception { + try { + $action + } catch (Corpus2::TagsetNotFound &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } inline const Tagset& get_named_tagset(const std::string& name); }