/usr/include/openturns/swig/OTexceptions.i is in libopenturns-dev 0.15-2.
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 | // SWIG file OTexceptions.i
// Author : $LastChangedBy: dutka $
// Date : $LastChangedDate: 2009-10-27 17:42:46 +0100 (Tue, 27 Oct 2009) $
// Id : $Id: OTexceptions.i 1382 2009-10-27 16:42:46Z dutka $
%{
#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::Base::Common::InvalidArgumentException & ex) {
SWIG_exception(SWIG_TypeError,ex.__repr__().c_str());
}
catch (OT::Base::Common::OutOfBoundException & ex) {
SWIG_exception(SWIG_IndexError,ex.__repr__().c_str());
}
catch (OT::Base::Common::Exception & ex) {
SWIG_exception(SWIG_RuntimeError,ex.__repr__().c_str());
}
catch (std::out_of_range & ex) {
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
%}
|