summaryrefslogtreecommitdiffstats
path: root/include/qapi
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-11-18 01:53:00 -0700
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:19 -0600
commitc525e43ff192894ab3ed7047843cc5e07f7c1775 (patch)
treef0d7974bd49fe40fdf5244857d5bdd5d7f3ecafe /include/qapi
parente597183c271c72e0fba4f02addeb3cf6cacd622e (diff)
downloadhqemu-c525e43ff192894ab3ed7047843cc5e07f7c1775.zip
hqemu-c525e43ff192894ab3ed7047843cc5e07f7c1775.tar.gz
qapi: Add alias for ErrorClass
The qapi enum ErrorClass is unusual that it uses 'CamelCase' names, contrary to our documented convention of preferring 'lower-case'. However, this enum is entrenched in the API; we cannot change what strings QMP outputs. Meanwhile, we want to simplify how c_enum_const() is used to generate enum constants, by moving away from the heuristics of camel_to_upper() to a more straightforward c_name(N).upper() - but doing so will rename all of the ErrorClass constants and cause churn to all client files, where the new names are aesthetically less pleasing (ERROR_CLASS_DEVICENOTFOUND looks like we can't make up our minds on whether to break between words). So as always in computer science, solve the problem by some more indirection: rename the qapi type to QapiErrorClass, and add a new enum ErrorClass in error.h whose members are aliases of the qapi type, but with the spelling expected elsewhere in the tree. Then, when c_enum_const() changes the munging, we only have to adjust the one alias spot. Suggested by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1447836791-369-26-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi')
-rw-r--r--include/qapi/error.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 4d42cdc..3060b0c 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -91,6 +91,20 @@
typedef struct Error Error;
/*
+ * Overall category of an error.
+ * Based on the qapi type QapiErrorClass, but reproduced here for nicer
+ * enum names.
+ */
+typedef enum ErrorClass {
+ ERROR_CLASS_GENERIC_ERROR = QAPI_ERROR_CLASS_GENERIC_ERROR,
+ ERROR_CLASS_COMMAND_NOT_FOUND = QAPI_ERROR_CLASS_COMMAND_NOT_FOUND,
+ ERROR_CLASS_DEVICE_ENCRYPTED = QAPI_ERROR_CLASS_DEVICE_ENCRYPTED,
+ ERROR_CLASS_DEVICE_NOT_ACTIVE = QAPI_ERROR_CLASS_DEVICE_NOT_ACTIVE,
+ ERROR_CLASS_DEVICE_NOT_FOUND = QAPI_ERROR_CLASS_DEVICE_NOT_FOUND,
+ ERROR_CLASS_KVM_MISSING_CAP = QAPI_ERROR_CLASS_KVM_MISSING_CAP,
+} ErrorClass;
+
+/*
* Get @err's human-readable error message.
*/
const char *error_get_pretty(Error *err);
OpenPOWER on IntegriCloud