On 05/16/2018 09:32 AM, Igor Mammedov wrote:
Actually, error_setg() is documented as taking a single phrase (no '.'
included), and that if you need a second sentence, it's better to use
error_append_hint().
well, using append_hint makes it less readable, before using it we get
following error:
$ qemu-system-x86_64 -numa dist,src=128,dst=1,val=20
qemu-system-x86_64: -numa dist,src=128,dst=1,val=20: Invalid node 128, The
valid node range is [0 - 127]
$
after using it we get:
$ qemu-system-x86_64 -numa dist,src=128,dst=1,val=20
qemu-system-x86_64: -numa dist,src=128,dst=1,val=20: Invalid node value 128
The valid node range is [0 - 127]$
i.e. an extra newline in the middle of error message and looses automatic
newline at the end so the shell prompt continues error message
Use of error_append_hint() requires you to provide a newline (unlike
error_setg(). But as Markus pointed out, you don't need to use it:
Correct. Providing help on valid values is exactly what
error_append_hint() is for.
Maybe Markus has an opinion on the best way to
word this error message.
Yes: "Parameter 'src' expects an integer between 0 and 127"
I like this wording better, which avoids the shortfalls that
error_append_hint() would introduce.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org