diff --git a/swig/exception.i b/swig/exception.i index 320866e4ee6c29e08c7e09c84173770fc3ee87c5..daddc14a9c9fdbe8a1d0a32e99441dc0ad9cc682 100644 --- a/swig/exception.i +++ b/swig/exception.i @@ -1,7 +1,7 @@ #ifndef LIBWCCL_EXCEPTION_H #define LIBWCCL_EXCEPTION_H -%module libcorpusexception +%module libwcclexception %{ #include <libpwrutils/exception.h> %} @@ -31,18 +31,6 @@ namespace Wccl { std::string arg_name; std::string reason; }; - - %exception { - try { - $action - } catch (Wccl::InvalidArgument &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; - } - } } using namespace std; diff --git a/swig/matchrulesequence.i b/swig/matchrulesequence.i index e6f7d6b62a5bc74fca6cefb714cdfb20b8488122..f5403da00a73a5aac0bffa02efe08b28c33e85df 100644 --- a/swig/matchrulesequence.i +++ b/swig/matchrulesequence.i @@ -32,14 +32,39 @@ namespace Matching { void operator()(const shared_ptr<Corpus2::AnnotatedSentence>& sentence); /* --------------------------------------------------------------------- */ - + %exception { + try { + $action + } catch (Wccl::WcclError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } void apply_all(const shared_ptr<Corpus2::AnnotatedSentence>& sentence); + + %exception { + try { + $action + } catch (Wccl::WcclError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } void apply_all_sentence_wrapper(const shared_ptr<Corpus2::Sentence>& sentence); /* --------------------------------------------------------------------- */ std::string to_string(const Corpus2::Tagset& tagset) const; }; + + %exception { + try { + $action + } catch (Wccl::WcclError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } } } diff --git a/swig/wccl.i b/swig/wccl.i index 6d85be88ee46ae1635048a6644d81d38b25e8316..329b902dfca3ef4f0909d33c9a4fa828e444a087 100644 --- a/swig/wccl.i +++ b/swig/wccl.i @@ -34,5 +34,6 @@ %include "lexicon.i" %include "lexicons.i" %include "wcclfile.i" +%include "exception.i" #endif /* SWIG_LIBWCCL_I */