From 13f59ae8157e8ec238fa8aefe5309909a1eeb7e2 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Fri, 27 Jul 2012 14:09:29 -0300 Subject: error, qerror: add ErrorClass argument to error functions The new argument is added to functions qerror_report() and error_set(). It's stored in Error and QError. qerror_report_err() is also updated to take care of it. The QERR_ macros are changed to contain a place holder value for the new argument, so that the value is used on all current calls to qerror_report() and error_set() (and also to initialize qerror_table[]). Next commit will update the QERR_ macros with a proper ErrorClass value. Signed-off-by: Luiz Capitulino Reviewed-by: Markus Armbruster --- error.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'error.c') diff --git a/error.c b/error.c index 2ade99b080..648706aa67 100644 --- a/error.c +++ b/error.c @@ -14,6 +14,7 @@ #include "error.h" #include "qjson.h" #include "qdict.h" +#include "qapi-types.h" #include "error_int.h" #include "qerror.h" @@ -21,9 +22,10 @@ struct Error { QDict *obj; char *msg; + ErrorClass err_class; }; -void error_set(Error **errp, const char *fmt, ...) +void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) { Error *err; va_list ap; @@ -39,6 +41,7 @@ void error_set(Error **errp, const char *fmt, ...) err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap)); va_end(ap); err->msg = qerror_format(fmt, err->obj); + err->err_class = err_class; *errp = err; } @@ -49,6 +52,7 @@ Error *error_copy(const Error *err) err_new = g_malloc0(sizeof(*err)); err_new->msg = g_strdup(err->msg); + err_new->err_class = err->err_class; err_new->obj = err->obj; QINCREF(err_new->obj); @@ -97,7 +101,7 @@ void error_free(Error *err) } } -bool error_is_type(Error *err, const char *fmt) +bool error_is_type(Error *err, ErrorClass err_class, const char *fmt) { const char *error_class; char *ptr; -- cgit v1.2.1