From 82f23ae5ce2cfcf30fe2e8ee800a72245388029b Mon Sep 17 00:00:00 2001
From: michal <michal@kalafior.(none)>
Date: Wed, 22 May 2013 13:15:37 +0200
Subject: [PATCH] przechwytywanie bledow WcclError w pythonie dla metody
 apply_all

---
 swig/exception.i         | 14 +-------------
 swig/matchrulesequence.i | 27 ++++++++++++++++++++++++++-
 swig/wccl.i              |  1 +
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/swig/exception.i b/swig/exception.i
index 320866e..daddc14 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 e6f7d6b..f5403da 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 6d85be8..329b902 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 */
-- 
GitLab