py_errors.h 468 B

123456789101112131415161718192021222324
  1. #pragma once
  2. #include <util/generic/fwd.h>
  3. namespace NPython {
  4. TString GetLastErrorAsString();
  5. #define PY_TRY try
  6. #define PY_CATCH(ErrorValue) \
  7. catch (const yexception& e) { \
  8. PyErr_SetString(PyExc_RuntimeError, e.what()); \
  9. return ErrorValue; \
  10. }
  11. #define PY_ENSURE(condition, message) \
  12. do { \
  13. if (Y_UNLIKELY(!(condition))) { \
  14. throw yexception() << message; \
  15. } \
  16. } while (0)
  17. } // namspace NPython