1 // Copyright (C) 2019 EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef PY2CPP_ERRORS_HXX
20 #define PY2CPP_ERRORS_HXX
29 * Retrieve the last python error and return it as a formated string, containing
30 * the traceback when possible.
31 * After the call of this function, the python error indicator is cleared.
34 std::string getLastPyError();
37 * ConversionCheck class gathers the errors within fromPy functions.
43 ConversionCheck(const std::string& error);
45 operator bool()const; //! true means no error
46 void addError(const std::string& expectedType, PyObject * obj);
47 void addError(const ConversionCheck& err);
48 void addErrorMessage(const std::string& message);
49 void reset(); //! Empty the error message.
50 const std::string& getMessage()const;
55 class Exception:public std::exception
58 Exception(const std::string& message);
59 virtual const char* what() const noexcept;
64 class ConversionException:public Exception
67 ConversionException(const std::string& message);
70 class ExecutionException:public Exception
73 ExecutionException(const std::string& message);
76 class AttributeException:public Exception
79 AttributeException(const std::string& message);
84 #endif //PY2CPP_ERRORS_HXX