All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	Thomas Huth <thuth@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/2] doc: Introduce coding style for errors
Date: Mon, 23 Nov 2015 19:41:24 +0100	[thread overview]
Message-ID: <144830408403.1693.5595372859320618258.stgit@localhost> (raw)
In-Reply-To: <144830407261.1693.6845199723252391860.stgit@localhost>

Gives some general guidelines for reporting errors in QEMU.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 HACKING |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/HACKING b/HACKING
index 12fbc8a..e59bc34 100644
--- a/HACKING
+++ b/HACKING
@@ -157,3 +157,34 @@ painful. These are:
  * you may assume that integers are 2s complement representation
  * you may assume that right shift of a signed integer duplicates
    the sign bit (ie it is an arithmetic shift, not a logical shift)
+
+7. Error reporting
+
+QEMU provides two different mechanisms for reporting errors. You should use one
+of these mechanisms instead of manually reporting them (i.e., do not use
+'printf', 'exit' or 'abort').
+
+7.1. Errors in user inputs
+
+QEMU provides the functions in "include/qemu/error-report.h" to report errors
+related to inputs provided by the user (e.g., command line arguments or
+configuration files).
+
+These functions generate error messages with a uniform format that can reference
+a location on the offending input.
+
+7.2. Other errors
+
+QEMU provides the functions in "include/qapi/error.h" to report other types of
+errors (i.e., not triggered by command line arguments or configuration files).
+
+Functions in this header are used to accumulate error messages in an 'Error'
+object, which can be propagated up the call chain where it is finally reported.
+
+In its simplest form, you can immediately report an error with:
+
+    error_setg(&error_warn, "Error with %s", "arguments");
+
+See the "include/qapi/error.h" header for additional convenience functions and
+special arguments. Specially, see 'error_fatal' and 'error_abort' to show errors
+and immediately terminate QEMU.

  parent reply	other threads:[~2015-11-23 18:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 18:41 [Qemu-devel] [RFC][PATCH v2 0/2] utils: Improve and document error reporting Lluís Vilanova
2015-11-23 18:41 ` [Qemu-devel] [PATCH v2 1/2] utils: Add warning messages Lluís Vilanova
2015-11-26 10:41   ` Markus Armbruster
2015-12-29 19:31     ` Lluís Vilanova
2015-11-23 18:41 ` Lluís Vilanova [this message]
2015-11-23 18:51   ` [Qemu-devel] [PATCH v2 2/2] doc: Introduce coding style for errors Daniel P. Berrange
2015-11-23 20:05     ` Lluís Vilanova
2015-11-23 20:36       ` Daniel P. Berrange
2015-11-24  7:30         ` Markus Armbruster
2015-11-24  7:20     ` Markus Armbruster
2015-11-24 15:04       ` Lluís Vilanova
2015-11-24 15:59         ` Markus Armbruster

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=144830408403.1693.5595372859320618258.stgit@localhost \
    --to=vilanova@ac.upc.edu \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.