diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2012-07-27 14:09:29 -0300 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-08-13 13:21:21 -0300 |
commit | 13f59ae8157e8ec238fa8aefe5309909a1eeb7e2 (patch) | |
tree | a60ca832661ef024c876a5315bfa1a0774032ef8 /error.c | |
parent | 85465051e0e8a79c3c1df3187c2acaacb10d6232 (diff) |
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 <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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; |