-/* Copyright (c) 2009, 2010 Nicira Networks
+/* Copyright (c) 2009, 2010, 2011 Nicira Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "util.h"
#include "vlog.h"
-VLOG_DEFINE_THIS_MODULE(ovsdb_error)
+VLOG_DEFINE_THIS_MODULE(ovsdb_error);
struct ovsdb_error {
const char *tag; /* String for "error" member. */
return error;
}
+/* Returns an ovsdb_error that represents an internal error for file name
+ * 'file' and line number 'line', with 'details' (formatted as with printf())
+ * as the associated message. The caller is responsible for freeing the
+ * returned error.
+ *
+ * If 'inner_error' is nonnull then the returned error is wrapped around
+ * 'inner_error'. Takes ownership of 'inner_error'. */
struct ovsdb_error *
-ovsdb_internal_error(const char *file, int line, const char *details, ...)
+ovsdb_internal_error(struct ovsdb_error *inner_error,
+ const char *file, int line, const char *details, ...)
{
struct ds ds = DS_EMPTY_INITIALIZER;
struct backtrace backtrace;
ds_put_format(&ds, " (%s %s%s)", program_name, VERSION, BUILDNR);
+ if (inner_error) {
+ char *s = ovsdb_error_to_string(inner_error);
+ ds_put_format(&ds, " (generated from: %s)", s);
+ free(s);
+
+ ovsdb_error_destroy(inner_error);
+ }
+
error = ovsdb_error("internal error", "%s", ds_cstr(&ds));
ds_destroy(&ds);
ovsdb_error_destroy(error);
}
}
-