From: Anthony Liguori <aliguori@us.ibm.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kraxel@redhat.com, qemu-devel@nongnu.org,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v0 0/9] QError
Date: Mon, 19 Oct 2009 09:11:17 -0500 [thread overview]
Message-ID: <4ADC7385.1080508@us.ibm.com> (raw)
In-Reply-To: <m3k4yrfrw4.fsf@crossbow.pond.sub.org>
Markus Armbruster wrote:
> I just caught up with this topic, and since there's no obvious one
> message to reply to, I just reply here.
>
> I agree with Anthony we better get the error reporting protocol
> approximately right the first time, and rushing it could lead to tears
> later on. Mind, I said "approximately right", not "perfect".
>
> However, there are more than one way to screw this up. One is certainly
> to fall short of client requirements in a way that is costly to fix
> (think incompatible protocol revision). Another is to overshoot them in
> a way that is costly to maintain. A third one is to spend too much time
> on figuring out the perfect solution.
>
> I believe our true problem is that we're still confused and/or
> disagreeing on client requirements, and this has led to a design that
> tries to cover all the conceivable bases, and feels overengineered to
> me.
>
> There are only so many complexity credits you can spend in a program,
> both globally and individually. I'm very, very wary of making error
> reporting more complex than absolutely, desperately necessary.
> Reporting errors should remain as easy as we can make it, for reasons
> that have already been mentioned by me and others:
>
> * The more cumbersome it is to report an error, the less it is done, and
> the more vaguely it is done. If you have to edit more than the error
> site to report an error accurately, then chances skyrocket that it
> won't be reported, or it'll be reported inaccurately. And not because
> coders are stupid or lazy, but because they make sensible use of their
> very limited complexity credits: if you can either get the job done
> with lousy error messages, or not get it done at all, guess what the
> smart choice is.
>
> * It's highly desirable for errors to do double duty as documentation.
> Code like this (random pick) doesn't need a comment:
>
> if (qemu_opt_get(opts, "vlan")) {
> qemu_error("The 'vlan' parameter is not valid with -netdev\n");
> return -1;
> }
>
Or:
if (qemu_opt_get(opts, "vlan")) {
throw InvalidParameter("The 'vlan' parameter is not valid with -netdev");
}
Which would become:
#define INVALID_PARAMETER "InvalidParameter"
if (qemu_opt_get(opts, "vlan")) {
qemu_error(INVALID_PARAMETER, "The 'vlan' parameter is not valid
with -netdev");
return -1;
}
And if we find that this is a common occurrance, we probably should do:
invalid_parameter("vlan", "-netdev");
Which would expand to:
asprintf(&buf, "The '%s' parameter is not valid with %s", param, option);
qemu_error_full("InvalidParameter", "{'param': %s, 'option': %s, 'desc':
%s}", param, option, desc);
The real fundamental requirements are:
1) In order to support high level languages, an error class is needed to
generate proper exceptions.
2) To integrate well into high level languages exception mechanisms, we
make errors first class objects.
3) Exceptions should have a string representation. desc is a standard
string representation.
There's really nothing complex here.
--
Regards,
Anthony Liguori
prev parent reply other threads:[~2009-10-19 14:11 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 16:56 [Qemu-devel] [PATCH v0 0/9] QError Luiz Capitulino
2009-10-13 16:56 ` [Qemu-devel] [PATCH 1/9] QDict: Introduce qdict_iter() Luiz Capitulino
2009-10-13 16:56 ` [Qemu-devel] [PATCH 2/9] check-qdict: Add test for qdict_iter() Luiz Capitulino
2009-10-13 16:57 ` [Qemu-devel] [PATCH 3/9] qmisc: Introduce qobject_from_va() Luiz Capitulino
2009-10-13 21:52 ` Markus Armbruster
2009-10-14 13:40 ` Luiz Capitulino
2009-10-14 14:27 ` [Qemu-devel] " Paolo Bonzini
2009-10-13 16:57 ` [Qemu-devel] [PATCH 4/9] Introduce QError Luiz Capitulino
2009-10-13 16:57 ` [Qemu-devel] [PATCH 5/9] monitor: QError support Luiz Capitulino
2009-10-13 21:59 ` Markus Armbruster
2009-10-14 13:14 ` [Qemu-devel] " Paolo Bonzini
2009-10-14 14:07 ` Markus Armbruster
2009-10-13 16:57 ` [Qemu-devel] [PATCH 6/9] QError: Add qdev not found error Luiz Capitulino
2009-10-14 23:02 ` Hollis Blanchard
2009-10-15 13:34 ` Luiz Capitulino
2009-10-15 17:16 ` Hollis Blanchard
2009-10-15 17:52 ` Luiz Capitulino
2009-10-15 18:13 ` Hollis Blanchard
2009-10-15 19:08 ` Luiz Capitulino
2009-10-15 20:13 ` Hollis Blanchard
2009-10-15 20:57 ` Anthony Liguori
2009-10-15 21:18 ` Hollis Blanchard
2009-10-15 21:27 ` Anthony Liguori
2009-10-15 22:44 ` Hollis Blanchard
2009-10-16 8:06 ` [Qemu-devel] " Paolo Bonzini
2009-10-16 13:05 ` Luiz Capitulino
2009-10-19 10:25 ` Daniel P. Berrange
2009-10-19 12:28 ` Luiz Capitulino
2009-10-19 12:42 ` Daniel P. Berrange
2009-10-16 13:39 ` Anthony Liguori
2009-10-18 4:25 ` [Qemu-devel] " Jamie Lokier
2009-10-18 12:17 ` [Qemu-devel] " Paolo Bonzini
2009-10-19 16:50 ` Hollis Blanchard
2009-10-19 21:16 ` Paolo Bonzini
2009-10-16 7:30 ` [Qemu-devel] " Gerd Hoffmann
2009-10-16 12:39 ` Luiz Capitulino
2009-10-16 13:34 ` [Qemu-devel] " Paolo Bonzini
2009-10-16 13:37 ` [Qemu-devel] " Anthony Liguori
2009-10-16 14:17 ` Luiz Capitulino
2009-10-16 17:28 ` [Qemu-devel] " Paolo Bonzini
2009-10-16 17:47 ` Anthony Liguori
2009-10-16 8:02 ` Paolo Bonzini
2009-10-18 4:28 ` Jamie Lokier
2009-10-18 4:34 ` Jamie Lokier
2009-10-13 16:57 ` [Qemu-devel] [PATCH 7/9] qdev: Use QError for " Luiz Capitulino
2009-10-13 22:34 ` Markus Armbruster
2009-10-14 13:29 ` [Qemu-devel] " Paolo Bonzini
2009-10-14 16:42 ` Luiz Capitulino
2009-10-14 14:51 ` [Qemu-devel] " Luiz Capitulino
2009-10-19 10:12 ` Daniel P. Berrange
2009-10-19 10:40 ` Gerd Hoffmann
2009-10-19 10:47 ` Daniel P. Berrange
2009-10-19 11:22 ` [Qemu-devel] " Paolo Bonzini
2009-10-19 14:00 ` [Qemu-devel] " Anthony Liguori
2009-10-19 15:21 ` Daniel P. Berrange
2009-10-19 15:27 ` Anthony Liguori
2009-10-19 15:39 ` Daniel P. Berrange
2009-10-13 16:57 ` [Qemu-devel] [PATCH 8/9] QError: Add do_info_balloon() errors Luiz Capitulino
2009-10-13 16:57 ` [Qemu-devel] [PATCH 9/9] monitor: do_info_balloon(): use QError Luiz Capitulino
2009-10-15 19:24 ` [Qemu-devel] [PATCH v0 0/9] QError Anthony Liguori
2009-10-15 19:37 ` Luiz Capitulino
2009-10-19 13:13 ` Markus Armbruster
2009-10-19 14:11 ` Anthony Liguori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ADC7385.1080508@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=kraxel@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).