error: don't delay error message construction
Today, the error message is only constructed when it's used. This commit
changes that to construct the error message when the error object is
built (ie. when the error is reported).
This simplifies the Error object.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff --git a/qerror.c b/qerror.c
index a254f88..5d38428 100644
--- a/qerror.c
+++ b/qerror.c
@@ -543,7 +543,6 @@
struct Error
{
QDict *obj;
- const char *fmt;
char *msg;
};
@@ -555,8 +554,7 @@
loc_save(&qerr->loc);
QINCREF(err->obj);
qerr->error = err->obj;
-
- qerr->err_msg = qerror_format(err->fmt, qerr->error);
+ qerr->err_msg = g_strdup(err->msg);
if (monitor_cur_is_qmp()) {
monitor_set_error(cur_mon, qerr);