diff --git a/swig/libcorpustokenreader.i b/swig/libcorpustokenreader.i index 935ba2159fcdfd9c23e1303ab6cfe52c6db738a2..93043ff8446bdb1adc53001c4da9781f2399dae1 100644 --- a/swig/libcorpustokenreader.i +++ b/swig/libcorpustokenreader.i @@ -30,11 +30,27 @@ namespace Corpus2 { virtual ~TokenReader(); /* --------------------------------------------------------------------- */ + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } static TokenReaderPtr create_path_reader( const std::string& class_id, const Tagset& tagset, const std::string& path); + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } static TokenReaderPtr create_stream_reader( const std::string& class_id, const Tagset& tagset, diff --git a/swig/libcorpustokenwriter.i b/swig/libcorpustokenwriter.i index 19e914f1ab7c8dc68c9d17b971cfd6c88475a9f7..50ad969ab890b83f4fe22fc2ef5156bddce69932 100644 --- a/swig/libcorpustokenwriter.i +++ b/swig/libcorpustokenwriter.i @@ -39,11 +39,27 @@ namespace Corpus2 { void finish(); /* --------------------------------------------------------------------- */ + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } static TokenWriterPtr create_stream_writer( const std::string& class_id_params, std::ostream& os, const Tagset& tagset); + %exception { + try { + $action + } catch (PwrNlp::PwrNlpError &e) { + PyErr_SetString(PyExc_IndexError, e.info().c_str()); + return NULL; + } + } static TokenWriterPtr create_path_writer( const std::string& class_id_params, const std::string& path,