/usr/include/openturns/swig/OTexceptions.i is in libopenturns-dev 1.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | // SWIG file OTexceptions.i
%{
#include "Exception.hxx"
%}
namespace std {
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char* what() const throw();
};
}
%include exception.i
%exception {
try {
$action
}
catch (OT::InvalidArgumentException & ex) {
SWIG_exception(SWIG_TypeError,ex.__repr__().c_str());
}
catch (OT::OutOfBoundException & ex) {
SWIG_exception(SWIG_IndexError,ex.__repr__().c_str());
}
catch (OT::Exception & ex) {
SWIG_exception(SWIG_RuntimeError,ex.__repr__().c_str());
}
catch (std::range_error & ex) {
SWIG_exception(SWIG_IndexError,ex.what());
}
catch (std::out_of_range & ex) {
SWIG_exception(SWIG_IndexError,ex.what());
}
catch (std::logic_error & ex) { // IDM : Glut Debian Squeeze with libstdc++ 4.4.5
SWIG_exception(SWIG_IndexError,ex.what());
}
catch (std::exception & ex) {
SWIG_exception(SWIG_RuntimeError,ex.what());
}
}
%pythoncode %{
class TestFailed:
"""TestFailed is used to raise an uniform exception in tests."""
__type = "TestFailed"
def __init__(self, reason=""):
self.reason = reason
def type(self):
return TestFailed.__type
def what(self):
return self.reason
def __str__(self):
return TestFailed.__type + ": " + self.reason
def __lshift__(self, ch):
self.reason += ch
return self
%}
|