Skip to content

Commit

Permalink
When json_load_file fails report the error details information (#103)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
barry-scott authored Nov 25, 2022
1 parent b52d190 commit dac0dd6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/keys.c
Original file line number Diff line number Diff line change
@@ -369,9 +369,12 @@ load_keys(const char* jwkdir)
continue;
}
filepath[sizeof(filepath) - 1] = '\0';
json_auto_t* json = json_load_file(filepath, 0, NULL);
json_error_t error;
json_auto_t* json = json_load_file(filepath, 0, &error);
if (!json) {
fprintf(stderr, "Invalid JSON file (%s); skipping\n", filepath);
fprintf(stderr, "Cannot load JSON file (%s); skipping\n", filepath);
fprintf(stderr, "error text %s, line %d, col %d, pos %d\n",
error.text, error.line, error.column, error.position);
continue;
}

0 comments on commit dac0dd6

Please sign in to comment.