[prev in list] [next in list] [prev in thread] [next in thread]
List: sanlock-devel
Subject: [PATCH 2/3] Improve error messages when validating disks
From: Nir Soffer <nsoffer () redhat ! com>
Date: 2022-11-27 19:17:29
Message-ID: 20221127191730.297519-3-nsoffer () redhat ! com
[Download RAW message or body]
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@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
_______________________________________________
sanlock-devel mailing list -- sanlock-devel@lists.fedorahosted.org
To unsubscribe send an email to sanlock-devel-leave@lists.fedorahosted.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/sanlock-devel@lists.fedorahosted.org
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic