Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsjOI-0002Qu-Cr for qemu-devel@nongnu.org; Fri, 19 Mar 2010 17:05:58 -0400 Received: from [199.232.76.173] (port=49287 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsjOH-0002QH-OP for qemu-devel@nongnu.org; Fri, 19 Mar 2010 17:05:57 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsjOG-0004F4-AJ for qemu-devel@nongnu.org; Fri, 19 Mar 2010 17:05:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46709) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsjOF-0004F0-Su for qemu-devel@nongnu.org; Fri, 19 Mar 2010 17:05:56 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2JL5tnK019891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Mar 2010 17:05:55 -0400 From: Markus Armbruster References: <1268929996-28763-1-git-send-email-armbru@redhat.com> <1268929996-28763-5-git-send-email-armbru@redhat.com> <20100319164929.74810d16@redhat.com> Date: Fri, 19 Mar 2010 22:05:53 +0100 In-Reply-To: <20100319164929.74810d16@redhat.com> (Luiz Capitulino's message of "Fri, 19 Mar 2010 16:49:29 -0300") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 04/11] error: New QERR_INVALID_PARAMETER_VALUE List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org Luiz Capitulino writes: > On Thu, 18 Mar 2010 17:33:11 +0100 > Markus Armbruster wrote: > >> >> Signed-off-by: Markus Armbruster >> --- >> qerror.c | 4 ++++ >> qerror.h | 3 +++ >> 2 files changed, 7 insertions(+), 0 deletions(-) >> >> diff --git a/qerror.c b/qerror.c >> index 9fb817e..97e8d4a 100644 >> --- a/qerror.c >> +++ b/qerror.c >> @@ -121,6 +121,10 @@ static const QErrorStringTable qerror_table[] = { >> .desc = "Invalid parameter type, expected: %(expected)", >> }, >> { >> + .error_fmt = QERR_INVALID_PARAMETER_VALUE, >> + .desc = "Parameter '%(name)' expects %(expected)", >> + }, > > Would we need this error if we improve QERR_INVALID_PARAMETER to > accept an optional 'expects' parameter? QERR_INVALID_PARAMETER_VALUE means "this value can't be accepted for this parameter". QERR_INVALID_PARAMETER means "this parameter can't be accepted, regardless of value". Pedantically speaking, that's a different error. Pragmatically speaking, I doubt clients care much (but I'm the one who doubts clients care much for differentiating errors in general, so I'm biased). Practically speaking, we can use a single error class 'InvalidParameter' if we don't care for the difference, but I figure we still need separate QERR_ definitions, because we want different human-readable error messages. Want me to do anything here now? >> + { >> .error_fmt = QERR_INVALID_PASSWORD, >> .desc = "Password incorrect", >> }, >> diff --git a/qerror.h b/qerror.h >> index 870cdc3..5625d54 100644 >> --- a/qerror.h >> +++ b/qerror.h >> @@ -106,6 +106,9 @@ QError *qobject_to_qerror(const QObject *obj); >> #define QERR_INVALID_PARAMETER_TYPE \ >> "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" >> >> +#define QERR_INVALID_PARAMETER_VALUE \ >> + "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }" >> + >> #define QERR_INVALID_PASSWORD \ >> "{ 'class': 'InvalidPassword', 'data': {} }" >>