37 lines
1.3 KiB
Diff
37 lines
1.3 KiB
Diff
From dac0dd6f729ed6cbdd4c92f5a8b2f5e1c66127fb Mon Sep 17 00:00:00 2001
|
|
From: Barry <barry@barrys-emacs.org>
|
|
Date: Fri, 25 Nov 2022 16:36:26 +0000
|
|
Subject: [PATCH] When json_load_file fails report the error details
|
|
information (#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.
|
|
---
|
|
src/keys.c | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/keys.c b/src/keys.c
|
|
index 205bbe5..bbfc374 100644
|
|
--- a/src/keys.c
|
|
+++ b/src/keys.c
|
|
@@ -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;
|
|
}
|
|
|
|
--
|
|
2.38.1
|
|
|