diff --git a/CMakeLists.txt b/CMakeLists.txt index 028b4e2bc9d3ff0076e01e3a6bca6461a1e813a5..47c667dd5c5879a51d4ee9f646dd9f8f0ce8dbd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.0) set(wccl_ver_major "0") set(wccl_ver_minor "3") -set(wccl_ver_patch "1") +set(wccl_ver_patch "2") set(LIBWCCL_VERSION "${wccl_ver_major}.${wccl_ver_minor}.${wccl_ver_patch}") diff --git a/swig/exception.i b/swig/exception.i new file mode 100644 index 0000000000000000000000000000000000000000..320866e4ee6c29e08c7e09c84173770fc3ee87c5 --- /dev/null +++ b/swig/exception.i @@ -0,0 +1,51 @@ +#ifndef LIBWCCL_EXCEPTION_H +#define LIBWCCL_EXCEPTION_H + +%module libcorpusexception +%{ + #include <libpwrutils/exception.h> +%} + +%include "std_string.i" + +%include "libpwrnlperror.i" + +namespace Wccl { + class WcclError : public PwrNlp::PwrNlpError { + public: + WcclError(const std::string &what); + ~WcclError() throw(); + + /* --------------------------------------------------------------------- */ + std::string scope() const; + }; + + class InvalidArgument : public WcclError { + public: + InvalidArgument(const std::string& arg_name, const std::string& reason); + + ~InvalidArgument() throw(); + + /* --------------------------------------------------------------------- */ + std::string info() const; + 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; +using namespace Wccl; + +#endif /* SWIG_LIBWCCL_EXCEPTION_I */ \ No newline at end of file