summaryrefslogtreecommitdiff
path: root/include/gras/exception.i
diff options
context:
space:
mode:
Diffstat (limited to 'include/gras/exception.i')
-rw-r--r--include/gras/exception.i18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/gras/exception.i b/include/gras/exception.i
new file mode 100644
index 0000000..5ed2cd3
--- /dev/null
+++ b/include/gras/exception.i
@@ -0,0 +1,18 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_EXCEPTION_I
+#define INCLUDED_GRAS_EXCEPTION_I
+
+////////////////////////////////////////////////////////////////////////
+// http://www.swig.org/Doc2.0/Library.html#Library_stl_exceptions
+////////////////////////////////////////////////////////////////////////
+%include <exception.i>
+
+%exception
+{
+ try{$action}
+ catch (const std::exception& e)
+ {SWIG_exception(SWIG_RuntimeError, e.what());}
+}
+
+#endif /*INCLUDED_GRAS_EXCEPTION_I*/