[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] authz-list-file: Improve an error message
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 2/2] authz-list-file: Improve an error message |
Date: |
Fri, 13 Nov 2020 13:54:22 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Fri, Nov 13, 2020 at 07:23:58AM +0100, Markus Armbruster wrote:
>> When qauthz_list_file_load() rejects JSON values other than JSON
>> object with a rather confusing error message:
>>
>> $ echo 1 | qemu-system-x86_64 -nodefaults -S -display none -object
>> authz-list-file,id=authz0,filename=/dev/stdin
>> qemu-system-x86_64: -object
>> authz-list-file,id=authz0,filename=/dev/stdin: Invalid parameter type for
>> 'obj', expected: dict
>>
>> Improve to
>>
>> qemu-system-x86_64: -object
>> authz-list-file,id=authz0,filename=/dev/stdin: File '/dev/stdin' must
>> contain a JSON object
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> authz/listfile.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Thanks!
>> diff --git a/authz/listfile.c b/authz/listfile.c
>> index 1421e674a4..da3a0e69a2 100644
>> --- a/authz/listfile.c
>> +++ b/authz/listfile.c
>> @@ -73,7 +73,8 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **errp)
>>
>> pdict = qobject_to(QDict, obj);
>> if (!pdict) {
>> - error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "obj", "dict");
>> + error_setg(errp, "File '%s' must contain a JSON object",
>> + fauthz->filename);
>
> This code pattern was copied from other places in QEMU which use the
> same QERR_INVALID_PARAMETER_TYPE. There are another 10 or so examples
> of this error message pattern.
Yes. My "[PATCH 00/10] Chipping away at qerror.h" fixes other patterns,
but not this one. I intend to chip some more, as time permits.