virJSONValueFromString: Prefix error message from 'json-c'

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>
This commit is contained in:
Peter Krempa 2024-10-25 16:12:50 +02:00
parent e71a510605
commit 354a3d2be4

View 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);