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

Andrea Bolognani abologna at redhat.com
Tue Feb 20 11:19:15 UTC 2018


On Tue, 2018-02-20 at 09:54 +0000, Daniel P. Berrangé wrote:
> > > +        case VIR_CONF_LAST:
> > >         default:
> > > +            virReportError(VIR_ERR_INTERNAL_ERROR,
> > > +                           _("Unexpected conf value type %d"), val->type);
> > >             return -1;
> > 
> > All these errors are presumably dead code that we only keep around in
> > case we broke something in other parts of the code.
> > 
> > Do we need specific user-friendly translated errors? Since we log the
> > function name as well, something like: "unhandled enum value %d" would
> > do.
> 
> The function name only gets into the logs - not the error reporting,
> so if someone does get an error raised, I don't want it to be a totally
> generic message that could come from literally anywhere in the codebase.

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.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list