mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
Merge pull request #32730 from tchaikov/wip-mgr-maybe-unused
mgr: better error handling when reading option Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
c63587ae35
@ -399,13 +399,23 @@ ceph_option_get(BaseMgrModule *self, PyObject *args)
|
||||
const Option *opt = g_conf().find_option(string(what));
|
||||
if (opt) {
|
||||
std::string value;
|
||||
int r = g_conf().get_val(string(what), &value);
|
||||
assert(r >= 0);
|
||||
switch (int r = g_conf().get_val(string(what), &value); r) {
|
||||
case -ENOMEM:
|
||||
PyErr_NoMemory();
|
||||
return nullptr;
|
||||
case -ENAMETOOLONG:
|
||||
PyErr_SetString(PyExc_ValueError, "value too long");
|
||||
return nullptr;
|
||||
default:
|
||||
ceph_assert(r == 0);
|
||||
break;
|
||||
}
|
||||
dout(10) << "ceph_option_get " << what << " found: " << value << dendl;
|
||||
return get_python_typed_option_value(opt->type, value);
|
||||
} else {
|
||||
dout(4) << "ceph_option_get " << what << " not found " << dendl;
|
||||
Py_RETURN_NONE;
|
||||
PyErr_Format(PyExc_KeyError, "option not found: %s", what);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user