Return None instead of KeyError for failure of BpfMap::lookup for missing key

This commit is contained in:
Pragyansh Chaturvedi
2025-11-24 23:51:08 +05:30
parent ffc5a9f15f
commit 3335e0471b

View File

@ -42,7 +42,7 @@ py::object BpfMap::lookup(const py::object &key) const {
value_span.data(), value_size_, BPF_ANY);
if (ret < 0) {
if (ret == -ENOENT)
throw py::key_error("Key not found in map '" + map_name_ + "'");
return py::none();
throw BpfException("Failed to lookup key in map '" + map_name_ +
"': " + std::strerror(-ret));
}