aboutsummaryrefslogtreecommitdiff
path: root/qerror.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2012-07-27 17:51:03 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2012-08-13 14:17:53 -0300
commitdf1e608a01eb0d55d6639d97f575dba37a44ac4a (patch)
treeba00f049fb700fd96202ef952fe600e7a05b3093 /qerror.c
parent7795b166d9d1e2b33d428f5acab6d0d5e617ee91 (diff)
error, qerror: pass desc string to error calls
This commit changes all QERR_ macros to contain a human message (ie. the desc string found in qerr_table[]) instead of a json dictionary in string format. Before this commit, error_set() and qerror_report() would receive a json dictionary in string format and build a qobject from it. Now, both function receive a human message instead and the qobject is not built anymore. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qerror.c')
-rw-r--r--qerror.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/qerror.c b/qerror.c
index 0bf8aec947..dda14273d5 100644
--- a/qerror.c
+++ b/qerror.c
@@ -342,45 +342,6 @@ static QError *qerror_new(void)
return qerr;
}
-static QDict *error_obj_from_fmt_no_fail(const char *fmt, va_list *va)
-{
- QObject *obj;
- QDict *ret;
-
- obj = qobject_from_jsonv(fmt, va);
- if (!obj) {
- fprintf(stderr, "invalid json in error dict '%s'\n", fmt);
- abort();
- }
- if (qobject_type(obj) != QTYPE_QDICT) {
- fprintf(stderr, "error is not a dict '%s'\n", fmt);
- abort();
- }
-
- ret = qobject_to_qdict(obj);
- obj = qdict_get(ret, "class");
- if (!obj) {
- fprintf(stderr, "missing 'class' key in '%s'\n", fmt);
- abort();
- }
- if (qobject_type(obj) != QTYPE_QSTRING) {
- fprintf(stderr, "'class' key value should be a string in '%s'\n", fmt);
- abort();
- }
-
- obj = qdict_get(ret, "data");
- if (!obj) {
- fprintf(stderr, "missing 'data' key in '%s'\n", fmt);
- abort();
- }
- if (qobject_type(obj) != QTYPE_QDICT) {
- fprintf(stderr, "'data' key value should be a dict in '%s'\n", fmt);
- abort();
- }
-
- return ret;
-}
-
/**
* qerror_from_info(): Create a new QError from error information
*
@@ -394,9 +355,8 @@ static QError *qerror_from_info(ErrorClass err_class, const char *fmt,
qerr = qerror_new();
loc_save(&qerr->loc);
+ qerr->err_msg = g_strdup_vprintf(fmt, *va);
qerr->err_class = err_class;
- qerr->error = error_obj_from_fmt_no_fail(fmt, va);
- qerr->err_msg = qerror_format(fmt, qerr->error);
return qerr;
}