tpism_exception.i - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tpism_exception.i (1072B)
---
1 %header%{
2 #include "pism_python.hh"
3 #include "util/pism_utilities.hh"
4 %}
5
6 %exception {
7 try {
8 {
9 pism::python::SigInstaller handler(SIGINT, pism::python::sigint_handler);
10 $action
11 }
12 int sig = pism::python::check_signal();
13 if (sig == SIGINT) {
14 PyErr_SetString(PyExc_KeyboardInterrupt, "");
15 return NULL;
16 } else if (sig) {
17 SWIG_exception(SWIG_RuntimeError, "Caught an unknown signal.");
18 return NULL;
19 }
20 }
21 catch(Swig::DirectorException &e) {
22 SWIG_exception(SWIG_RuntimeError, e.getMessage());
23 }
24 catch (...) {
25 SWIG_exception(SWIG_RuntimeError, "Caught an unexpected C++ exception");
26 }
27 }
28
29 /* FIXME: this completely overrides the %exception block above. I need
30 to fix this. -- CK */
31 %include exception.i
32 %exception {
33 try {
34 $action
35 } catch (pism::RuntimeError &e) {
36 SWIG_exception(SWIG_RuntimeError, e.what());
37 } catch (std::exception &e) {
38 SWIG_exception(SWIG_UnknownError, e.what());
39 } catch (...) {
40 SWIG_exception(SWIG_UnknownError, "unknown C++ exception");
41 }
42 }
43