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 <vsement...@virtuozzo.com> --- 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