mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: improve JSON error reporting in spa-json-dump
This commit is contained in:
parent
04c5d3958b
commit
a9fdc6a408
2 changed files with 5 additions and 4 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/utils/json.h>
|
#include <spa/utils/json.h>
|
||||||
|
#include <spa/debug/file.h>
|
||||||
|
|
||||||
static void encode_string(FILE *f, const char *val, int len)
|
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;
|
struct spa_error_location loc;
|
||||||
|
|
||||||
if (spa_json_get_error(&it, buf, &loc))
|
if (spa_json_get_error(&it, buf, &loc))
|
||||||
fprintf(stderr, "syntax error in file '%s': at line:%d col:%d: %s\n",
|
spa_debug_file_error_location(stderr, &loc,
|
||||||
filename, loc.line, loc.col, loc.reason);
|
"syntax error in file '%s': %s",
|
||||||
|
filename, loc.reason);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "error parsing file '%s': %s\n", filename, spa_strerror(res));
|
fprintf(stderr, "error parsing file '%s': %s\n", filename, spa_strerror(res));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)) {
|
if (spa_json_get_error(&it[0], json, &loc)) {
|
||||||
spa_debug_file_error_location(stderr, &loc,
|
spa_debug_file_error_location(stderr, &loc,
|
||||||
"JSON syntax error: %s\n",
|
"JSON syntax error: %s\n", loc.reason);
|
||||||
loc.reason);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue