summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-11-17 17:05:49 +0100
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:24 -0600
commitaff6a93abbc8412cb53c02a136deaaa39469ac72 (patch)
tree3f39e76a9a081e01f0f2f04eab1444cba37478bc
parent4ab937854b4e2be2718e9bb6fd8f79460dfb714f (diff)
downloadhqemu-aff6a93abbc8412cb53c02a136deaaa39469ac72.zip
hqemu-aff6a93abbc8412cb53c02a136deaaa39469ac72.tar.gz
error: Document how to accumulate multiple errors
Suggested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1447776349-2344-1-git-send-email-armbru@redhat.com>
-rw-r--r--include/qapi/error.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 6285cf5..1480f59 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -76,6 +76,23 @@
* But when all you do with the error is pass it on, please use
* foo(arg, errp);
* for readability.
+ *
+ * Receive and accumulate multiple errors (first one wins):
+ * Error *err = NULL, *local_err = NULL;
+ * foo(arg, &err);
+ * bar(arg, &local_err);
+ * error_propagate(&err, local_err);
+ * if (err) {
+ * handle the error...
+ * }
+ *
+ * Do *not* "optimize" this to
+ * foo(arg, &err);
+ * bar(arg, &err); // WRONG!
+ * if (err) {
+ * handle the error...
+ * }
+ * because this may pass a non-null err to bar().
*/
#ifndef ERROR_H
OpenPOWER on IntegriCloud