Skip to content

Commit dac0dd6

Browse files
authored
When json_load_file fails report the error details information (latchset#103)
* When json_load_file fails report the error details information returned. This allows for file I/O issues as well as JSON parsing issues to be reported.
1 parent b52d190 commit dac0dd6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/keys.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,12 @@ load_keys(const char* jwkdir)
369369
continue;
370370
}
371371
filepath[sizeof(filepath) - 1] = '\0';
372-
json_auto_t* json = json_load_file(filepath, 0, NULL);
372+
json_error_t error;
373+
json_auto_t* json = json_load_file(filepath, 0, &error);
373374
if (!json) {
374-
fprintf(stderr, "Invalid JSON file (%s); skipping\n", filepath);
375+
fprintf(stderr, "Cannot load JSON file (%s); skipping\n", filepath);
376+
fprintf(stderr, "error text %s, line %d, col %d, pos %d\n",
377+
error.text, error.line, error.column, error.position);
375378
continue;
376379
}
377380

0 commit comments

Comments
 (0)