Previously we reported:
Invalid disk: 42
Both when checking that a disk is a tuple, and when failing to parse the
tuple. This makes it hard to debug the failure.
Use unique error message for each case:
Disk is not a tuple: 42
Cannot parse disk: ('path', 0, 'extra')
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
python/sanlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index db8fb27..cd6d4b0 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -157,27 +157,27 @@ validate_path(PyObject *path)
}
static int
parse_single_disk(PyObject* disk, struct sanlk_disk* res_disk)
{
int rv = 0;
PyObject *path = NULL;
uint64_t offset;
if (!PyTuple_Check(disk)) {
- set_error(PyExc_ValueError, "Invalid disk %s", disk);
+ set_error(PyExc_ValueError, "Disk is not a tuple: %s", disk);
goto finally;
}
if (!PyArg_ParseTuple(disk, "O&K", pypath_converter, &path,
&offset)) {
/* Override the error since it confusing in this context. */
- set_error(PyExc_ValueError, "Invalid disk %s", disk);
+ set_error(PyExc_ValueError, "Cannot parse disk: %s", disk);
goto finally;
}
if (!validate_path(path))
goto finally;
strncpy(res_disk->path, PyBytes_AsString(path), SANLK_PATH_LEN - 1);
res_disk->offset = offset;
rv = 1;
--
2.38.1