MCPcopy Create free account
hub / github.com/catboost/catboost / CallWithErrorTranslation

Function CallWithErrorTranslation

library/python/runtime_py3/__res.cpp:18–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16template<typename F>
17 requires std::convertible_to<std::invoke_result_t<F>, PyObject*>
18PyObject* CallWithErrorTranslation(F&& f) noexcept {
19 try {
20 return std::forward<F>(f)();
21 } catch (const std::bad_alloc& err) {
22 PyErr_SetString(PyExc_MemoryError, err.what());
23 } catch(const std::out_of_range& err) {
24 PyErr_SetString(PyExc_IndexError, err.what());
25 } catch (const std::exception& err) {
26 PyErr_SetString(PyExc_RuntimeError, err.what());
27 } catch(...) {
28 PyErr_SetString(PyExc_RuntimeError, "Unhandled C++ exception of unknown type");
29 }
30 return nullptr;
31}
32
33PyObject* Count(PyObject* self[[maybe_unused]], PyObject *args[[maybe_unused]]) noexcept {
34 static_assert(

Callers 3

KeyByIndexFunction · 0.85
FindFunction · 0.85
HasFunction · 0.85

Calls 1

whatMethod · 0.45

Tested by

no test coverage detected