diff options
Diffstat (limited to 'lib/ovsdb-error.c')
-rw-r--r-- | lib/ovsdb-error.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ovsdb-error.c b/lib/ovsdb-error.c index 9b1af68c6..a75ad36b7 100644 --- a/lib/ovsdb-error.c +++ b/lib/ovsdb-error.c @@ -203,6 +203,8 @@ ovsdb_error_clone(const struct ovsdb_error *old) } } +/* Returns 'error' converted to the <error> JSON object format described in RFC + * 7047. The caller must free the returned json (with json_destroy()). */ struct json * ovsdb_error_to_json(const struct ovsdb_error *error) { @@ -211,6 +213,8 @@ ovsdb_error_to_json(const struct ovsdb_error *error) if (error->details) { json_object_put_string(json, "details", error->details); } + + /* These are RFC 7047-compliant extensions. */ if (error->syntax) { json_object_put_string(json, "syntax", error->syntax); } @@ -218,6 +222,19 @@ ovsdb_error_to_json(const struct ovsdb_error *error) json_object_put_string(json, "io-error", ovs_retval_to_string(error->errno_)); } + + return json; +} + +/* Returns 'error' converted to the <error> JSON object format described in RFC + * 7047. The caller must free the returned json (with json_destroy()). + * + * Also, frees 'error'. */ +struct json * +ovsdb_error_to_json_free(struct ovsdb_error *error) +{ + struct json *json = ovsdb_error_to_json(error); + ovsdb_error_destroy(error); return json; } |