%include "exception.i" %exception { try { $action } catch (const std::exception &e) { SWIG_exception_fail(SWIG_RuntimeError, e.what()); } } %module mylib %{ /* Put headers and other declarations here */ #include "library.h" %} %include "std_vector.i" %include "std_string.i" %include "library.h"