Browse Source

util/error: make func optional

The function name is not available in Rust, so make it optional.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/287/head
Paolo Bonzini 1 year ago
parent
commit
e8fb9c91a3
  1. 2
      include/qapi/error-internal.h
  2. 9
      util/error.c

2
include/qapi/error-internal.h

@ -18,6 +18,8 @@ struct Error
{
char *msg;
ErrorClass err_class;
/* Used for error_abort only, may be NULL. */
const char *func;
/*

9
util/error.c

@ -24,8 +24,13 @@ Error *error_warn;
static void error_handle(Error **errp, Error *err)
{
if (errp == &error_abort) {
fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
err->func, err->src_len, err->src, err->line);
if (err->func) {
fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
err->func, err->src_len, err->src, err->line);
} else {
fprintf(stderr, "Unexpected error at %.*s:%d:\n",
err->src_len, err->src, err->line);
}
error_report("%s", error_get_pretty(err));
if (err->hint) {
error_printf("%s", err->hint->str);

Loading…
Cancel
Save