Commit 2ee2f1e4 authored by Markus Armbruster's avatar Markus Armbruster
Browse files

error: New convenience function error_report_err()



I've typed error_report("%s", error_get_pretty(ERR)) too many times
already, and I've fixed too many instances of qerror_report_err(ERR)
to error_report("%s", error_get_pretty(ERR)) as well.  Capture the
pattern in a convenience function.

Since it's almost invariably followed by error_free(), stuff that into
the convenience function as well.

The next patch will put it to use.

Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent 248337e1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ Error *error_copy(const Error *err);
 */
const char *error_get_pretty(Error *err);

/**
 * Convenience function to error_report() and free an error object.
 */
void error_report_err(Error *);

/**
 * Propagate an error to an indirect pointer to an error.  This function will
 * always transfer ownership of the error reference and handles the case where
+6 −0
Original line number Diff line number Diff line
@@ -152,6 +152,12 @@ const char *error_get_pretty(Error *err)
    return err->msg;
}

void error_report_err(Error *err)
{
    error_report("%s", error_get_pretty(err));
    error_free(err);
}

void error_free(Error *err)
{
    if (err) {