1 // Copyright (C) 2019-2024 EDF
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
22 #include "py2cppExports.hxx"
31 * Retrieve the last python error and return it as a formated string, containing
32 * the traceback when possible.
33 * After the call of this function, the python error indicator is cleared.
36 PY2CPP_EXPORT std::string getLastPyError();
39 * ConversionCheck class gathers the errors within fromPy functions.
41 class PY2CPP_EXPORT ConversionCheck
45 ConversionCheck(const std::string& error);
47 operator bool()const; //! true means no error
48 void addError(const std::string& expectedType, PyObject * obj);
49 void addError(const ConversionCheck& err);
50 void addErrorMessage(const std::string& message);
51 void reset(); //! Empty the error message.
52 const std::string& getMessage()const;
57 class PY2CPP_EXPORT Exception:public std::exception
60 Exception(const std::string& message);
61 virtual const char* what() const noexcept;
66 class PY2CPP_EXPORT ConversionException:public Exception
69 ConversionException(const std::string& message);
72 class PY2CPP_EXPORT ExecutionException:public Exception
75 ExecutionException(const std::string& message);
78 class PY2CPP_EXPORT AttributeException:public Exception
81 AttributeException(const std::string& message);
86 #endif //PY2CPP_ERRORS_HXX