spa: improve JSON error reporting in spa-json-dump

This commit is contained in:
Wim Taymans 2024-03-27 15:57:39 +01:00
parent 04c5d3958b
commit a9fdc6a408
2 changed files with 5 additions and 4 deletions

View File

@ -14,6 +14,7 @@
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/debug/file.h>
static void encode_string(FILE *f, const char *val, int len)
{
@ -143,8 +144,9 @@ static int process_json(const char *filename, void *buf, size_t size)
struct spa_error_location loc;
if (spa_json_get_error(&it, buf, &loc))
fprintf(stderr, "syntax error in file '%s': at line:%d col:%d: %s\n",
filename, loc.line, loc.col, loc.reason);
spa_debug_file_error_location(stderr, &loc,
"syntax error in file '%s': %s",
filename, loc.reason);
else
fprintf(stderr, "error parsing file '%s': %s\n", filename, spa_strerror(res));

View File

@ -1317,8 +1317,7 @@ static int get_data_from_json(struct data *data, const char *json_path)
if (spa_json_get_error(&it[0], json, &loc)) {
spa_debug_file_error_location(stderr, &loc,
"JSON syntax error: %s\n",
loc.reason);
"JSON syntax error: %s\n", loc.reason);
return -1;
}