On Thu, 13 Dec 2012 16:40:35 +0100 Pavel Hrdina <phrd...@redhat.com> wrote:
> Signed-off-by: Pavel Hrdina <phrd...@redhat.com> > --- > error.c | 8 ++++++++ > error.h | 6 ++++++ > 2 files changed, 14 insertions(+) > > diff --git a/error.c b/error.c > index 128d88c..dd3ab66 100644 > --- a/error.c > +++ b/error.c > @@ -113,3 +113,11 @@ void error_propagate(Error **dst_err, Error *local_err) > error_free(local_err); > } > } > + > +void handle_error(Error **errp) > +{ > + if (error_is_set(errp)) { > + error_report("%s", error_get_pretty(*errp)); > + error_free(*errp); > + } This is not good for a few reasons. The most important ones are that we most probably shouldn't be using error_report() in new qapi code. The other reason is that this function doesn't actually handle the error. I've added a similar function in hmp.c but just to save some typing, but we shouldn't do this elsewhere. > +} > diff --git a/error.h b/error.h > index 4d52e73..6a6acb5 100644 > --- a/error.h > +++ b/error.h > @@ -77,4 +77,10 @@ void error_propagate(Error **dst_err, Error *local_err); > */ > void error_free(Error *err); > > +/** > + * Print an error object as pretty string to current monitor or on stderr, > then > + * free the errot object. > + */ > +void handle_error(Error **errp); > + > #endif