[libvirt] [PATCH v2 02/42] util: handle missing switch enum cases

Andrea Bolognani abologna at redhat.com
Tue Feb 20 12:05:23 UTC 2018


On Tue, 2018-02-20 at 11:25 +0000, Daniel P. Berrangé wrote:
> > Yesterday I argued in a different thread that it would be better
> > to include the enum name in the error message, since that's useful
> > information for developers whereas users 1) should never see this
> > kind of error to begin with and 2) when they do, their only course
> > of action is reporting the issue anyway.
> 
> How about we standard it via a special API
> 
>    virReportErrorEnumRange(virDomainControllerModelUSB, val->type);
> 
> and map this through to a VIR_ERR_ENUM_RANGE error code, with a fixed
> string format.
> 
>    "Value '%d' out of range for enum %s"

Sounds like a good idea! We could even add something like

  This is a bug in libvirt, please report it.

or similar to make it clear that the user is not at fault.

Not sure about using a separate error code rather than the existing
INTERNAL_ERROR, though: it seems like it would not really buy us
anything.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list