diff options
author | shumkovnd <shumkovnd@yandex-team.com> | 2023-11-10 14:39:34 +0300 |
---|---|---|
committer | shumkovnd <shumkovnd@yandex-team.com> | 2023-11-10 16:42:24 +0300 |
commit | 77eb2d3fdcec5c978c64e025ced2764c57c00285 (patch) | |
tree | c51edb0748ca8d4a08d7c7323312c27ba1a8b79a /contrib/python/matplotlib/py3/src/py_exceptions.h | |
parent | dd6d20cadb65582270ac23f4b3b14ae189704b9d (diff) | |
download | ydb-77eb2d3fdcec5c978c64e025ced2764c57c00285.tar.gz |
KIKIMR-19287: add task_stats_drawing script
Diffstat (limited to 'contrib/python/matplotlib/py3/src/py_exceptions.h')
-rw-r--r-- | contrib/python/matplotlib/py3/src/py_exceptions.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/contrib/python/matplotlib/py3/src/py_exceptions.h b/contrib/python/matplotlib/py3/src/py_exceptions.h new file mode 100644 index 0000000000..c4accf2634 --- /dev/null +++ b/contrib/python/matplotlib/py3/src/py_exceptions.h @@ -0,0 +1,72 @@ +/* -*- mode: c++; c-basic-offset: 4 -*- */ + +#ifndef MPL_PY_EXCEPTIONS_H +#define MPL_PY_EXCEPTIONS_H + +#include <exception> +#include <stdexcept> + +namespace py +{ +class exception : public std::exception +{ + public: + const char *what() const throw() + { + return "python error has been set"; + } +}; +} + +#define CALL_CPP_FULL(name, a, cleanup, errorcode) \ + try \ + { \ + a; \ + } \ + catch (const py::exception &) \ + { \ + { \ + cleanup; \ + } \ + return (errorcode); \ + } \ + catch (const std::bad_alloc &) \ + { \ + PyErr_Format(PyExc_MemoryError, "In %s: Out of memory", (name)); \ + { \ + cleanup; \ + } \ + return (errorcode); \ + } \ + catch (const std::overflow_error &e) \ + { \ + PyErr_Format(PyExc_OverflowError, "In %s: %s", (name), e.what()); \ + { \ + cleanup; \ + } \ + return (errorcode); \ + } \ + catch (const std::runtime_error &e) \ + { \ + PyErr_Format(PyExc_RuntimeError, "In %s: %s", (name), e.what()); \ + { \ + cleanup; \ + } \ + return (errorcode); \ + } \ + catch (...) \ + { \ + PyErr_Format(PyExc_RuntimeError, "Unknown exception in %s", (name)); \ + { \ + cleanup; \ + } \ + return (errorcode); \ + } + +#define CALL_CPP_CLEANUP(name, a, cleanup) CALL_CPP_FULL(name, a, cleanup, 0) + +#define CALL_CPP(name, a) CALL_CPP_FULL(name, a, , 0) + +#define CALL_CPP_INIT(name, a) CALL_CPP_FULL(name, a, , -1) + +#endif |