diff --git a/python/recipe.cpp b/python/recipe.cpp index 16f78494f8..2649ba6bdf 100644 --- a/python/recipe.cpp +++ b/python/recipe.cpp @@ -188,7 +188,8 @@ void register_recipe(pybind11::module& m) { .def("cell_description", &py_recipe::cell_description, pybind11::return_value_policy::copy, "gid"_a, "High level description of the cell with global identifier gid.") - .def("cell_kind", &py_recipe::cell_kind, + .def("cell_kind", + &py_recipe::cell_kind, "gid"_a, "The kind of cell with global identifier gid.") .def("event_generators", &py_recipe::event_generators, diff --git a/python/recipe.hpp b/python/recipe.hpp index fe7624138a..8462b88138 100644 --- a/python/recipe.hpp +++ b/python/recipe.hpp @@ -64,7 +64,12 @@ class py_recipe_trampoline: public py_recipe { } arb::cell_kind cell_kind(arb::cell_gid_type gid) const override { - PYBIND11_OVERRIDE_PURE(arb::cell_kind, py_recipe, cell_kind, gid); + try { + PYBIND11_OVERRIDE_PURE(arb::cell_kind, py_recipe, cell_kind, gid); + } + catch (const pybind11::cast_error& e) { + throw pybind11::type_error{"Couldn't convert return value of recipe.cell_kind(gid) to a cell_kind. Please check your recipe."}; + } } std::vector event_generators(arb::cell_gid_type gid) const override {