qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] error: add error_get_hint


From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-devel] [PATCH 1/3] error: add error_get_hint
Date: Fri, 2 Nov 2018 18:11:50 +0300

Add a function to export error hint - a pair to error_get_pretty. It's
needed to handle errors by hand, where we can't just report it or
propagate.

Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
 include/qapi/error.h | 5 +++++
 util/error.c         | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 51b63dd4b5..ff2f61b877 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -139,6 +139,11 @@ typedef enum ErrorClass {
  */
 const char *error_get_pretty(const Error *err);
 
+/*
+ * Get @err's hint if any. Otherwise return NULL.
+ */
+const char *error_get_hint(const Error *err);
+
 /*
  * Get @err's error class.
  * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is
diff --git a/util/error.c b/util/error.c
index b5ccbd8eac..e7cedd5c4a 100644
--- a/util/error.c
+++ b/util/error.c
@@ -223,6 +223,11 @@ const char *error_get_pretty(const Error *err)
     return err->msg;
 }
 
+const char *error_get_hint(const Error *err)
+{
+    return err->hint ? err->hint->str : NULL;
+}
+
 void error_report_err(Error *err)
 {
     error_report("%s", error_get_pretty(err));
-- 
2.18.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]