From ec1b1e222f8465b47e38c0f525fc1b954c63ba5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl> Date: Fri, 6 May 2011 11:56:30 +0200 Subject: [PATCH] Handle for get_named_tagset exception --- swig/libcorpustagsetmanager.i | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/swig/libcorpustagsetmanager.i b/swig/libcorpustagsetmanager.i index d0d7f08..adc0b4c 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); } -- GitLab