virsh: Improve error message on integer value parsing failure.

Replace more than 30 ad-hoc error messages with a single, generic one
that contains the name of the option being processed and some hints
to help the user understand what could have gone wrong.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207043
This commit is contained in:
Andrea Bolognani
2015-05-15 18:14:39 +02:00
committed by Michal Privoznik
parent 8ed0bcfd81
commit 449316701b
7 changed files with 135 additions and 49 deletions

View File

@@ -341,8 +341,9 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
* This is not really an unsigned long, but it
*/
if ((rv = vshCommandOptInt(cmd, "period", &period)) < 0) {
vshError(ctl, "%s",
_("Unable to parse integer parameter."));
vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"),
"period");
goto cleanup;
}
if (rv > 0) {
@@ -1439,8 +1440,9 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd)
if (rv < 0) {
/* invalid integer format */
vshError(ctl, "%s",
_("Unable to parse integer parameter to --time."));
vshError(ctl,
_("Numeric value for <%s> option is malformed or out of range"),
"time");
goto cleanup;
} else if (rv > 0) {
/* valid integer to set */