From a18fc1b0f8ab56b2422c2da8188b5c9b3d612ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl> Date: Thu, 24 Nov 2011 13:49:54 +0100 Subject: [PATCH] Handle Exceptions in docreader wrapper. --- swig/documentreader.i | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/swig/documentreader.i b/swig/documentreader.i index 1a4bf31..df1a87d 100644 --- a/swig/documentreader.i +++ b/swig/documentreader.i @@ -6,13 +6,31 @@ #include <libcorpus2/io/docreader.h> %} +%include "exception.i" %include "document.i" %include "boost_shared_ptr.i" namespace Corpus2 { class DocumentReader { public: + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } DocumentReader(const Tagset&, const std::string&, const std::string &); + + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } boost::shared_ptr<Document> read(); /* --------------------------------------------------------------------- */ -- GitLab