eigenpy 3.12.0
Bindings between Numpy and Eigen using Boost.Python
Loading...
Searching...
No Matches
exception.hpp
1/*
2 * Copyright 2014-2019, CNRS
3 * Copyright 2018-2019, INRIA
4 */
5
6#ifndef __eigenpy_exception_hpp__
7#define __eigenpy_exception_hpp__
8
9#include <exception>
10#include <string>
11
12#include "eigenpy/fwd.hpp"
13
14namespace eigenpy {
15/*
16 * Eigenpy exception. They can be catch with python (equivalent
17 * eigenpy.exception class).
18 */
19class Exception : public std::exception {
20 public:
21 Exception() : message() {}
22 Exception(const std::string &msg) : message(msg) {}
23 const char *what() const throw() { return this->getMessage().c_str(); }
24 ~Exception() throw() {}
25 virtual const std::string &getMessage() const { return message; }
26 std::string copyMessage() const { return getMessage(); }
27
28 /* Call this static function to "enable" the translation of this C++ exception
29 * in Python. */
30 static void registerException();
31
32 private:
33 static void translateException(Exception const &e);
34 static PyObject *pyType;
35
36 protected:
37 std::string message;
38};
39
40} // namespace eigenpy
41
42#endif // ifndef __eigenpy_exception_hpp__