From c3fa500709b02692f72dcaa31644ae97a140b216 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Mon, 5 Mar 2012 17:43:39 -0500 Subject: [PATCH 12/98] QError: Introduce qerror_format() Will be used by new error propagation framework to convert Error objects into human-readable form. Signed-off-by: Luiz Capitulino Signed-off-by: Michael Roth Signed-off-by: Anthony Liguori (cherry picked from commit 87c2f59166b7ec5b3ce44b5c4a2337c07a78e533) Conflicts: qerror.h Signed-off-by: Jeff Cody Signed-off-by: Michal Novotny --- qerror.c | 15 +++++++++++++++ qerror.h | 1 + 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/qerror.c b/qerror.c index 804e7ab..5f0668d 100644 --- a/qerror.c +++ b/qerror.c @@ -418,6 +418,21 @@ static QString *qerror_format_desc(QDict *error, return qstring; } +QString *qerror_format(const char *fmt, QDict *error) +{ + const QErrorStringTable *entry = NULL; + int i; + + for (i = 0; qerror_table[i].error_fmt; i++) { + if (strcmp(qerror_table[i].error_fmt, fmt) == 0) { + entry = &qerror_table[i]; + break; + } + } + + return qerror_format_desc(error, entry); +} + /** * qerror_human(): Format QError data into human-readable string. */ diff --git a/qerror.h b/qerror.h index 349ef1f..3a9c000 100644 --- a/qerror.h +++ b/qerror.h @@ -40,6 +40,7 @@ void qerror_print(QError *qerror); void qerror_report_internal(const char *file, int linenr, const char *func, const char *fmt, ...) __attribute__ ((format(printf, 4, 5))); +QString *qerror_format(const char *fmt, QDict *error); #define qerror_report(fmt, ...) \ qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) QError *qobject_to_qerror(const QObject *obj); -- 1.7.7.6