From 84a1ab5307b104755c0d98647eddffda140d9053 Mon Sep 17 00:00:00 2001 From: thorstenhater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 31 May 2021 11:03:54 +0200 Subject: [PATCH] Raise KeyError in catalogue. (#1563) * Raise KeyError in catalogue. * Raise KeyError in label_dict. --- python/cells.cpp | 2 +- python/mechanism.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cells.cpp b/python/cells.cpp index 9b136b03..447a725a 100644 --- a/python/cells.cpp +++ b/python/cells.cpp @@ -220,7 +220,7 @@ void register_cells(pybind11::module& m) { .def("__getitem__", [](label_dict_proxy& l, const char* name) { if (!l.cache.count(name)) { - throw std::runtime_error(util::pprintf("\nKeyError: '{}'", name)); + throw pybind11::key_error(name); } return l.cache.at(name); }) diff --git a/python/mechanism.cpp b/python/mechanism.cpp index a2c93be2..18dab8fe 100644 --- a/python/mechanism.cpp +++ b/python/mechanism.cpp @@ -135,7 +135,7 @@ void register_mechanisms(pybind11::module& m) { return c[name]; } catch (...) { - throw std::runtime_error(util::pprintf("\nKeyError: '{}'", name)); + throw pybind11::key_error(name); } }) .def("extend", &arb::mechanism_catalogue::import, -- GitLab