]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virJSONValueFromString: Prefix error message from 'json-c'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 25 Oct 2024 14:12:50 +0000 (16:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 1 Nov 2024 14:51:53 +0000 (15:51 +0100)
The error message from 'json-c' was passed along without any libvirt
string which makes it hard to find in the source and isn't exactly clear
when present in logs:

 libvirtd[843]: internal error : invalid utf-8 string

Prefix the message with 'failed to parse JSON'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virjson.c

index 42018a98b4dfc416b59181b5d74fbf120aad1f15..4a95e84f5b62e6951f8d33352cb063eda3caafa6 100644 (file)
@@ -1467,7 +1467,8 @@ virJSONValueFromString(const char *jsonstring)
     jerr = json_tokener_get_error(tok);
     if (jerr != json_tokener_success) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", json_tokener_error_desc(jerr));
+                       _("failed to parse JSON: %1$s"),
+                       json_tokener_error_desc(jerr));
         goto cleanup;
     }
     ret = virJSONValueFromJsonC(jobj);