diff options
| -rw-r--r-- | src/json.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c index 47c5b8ff468..1c9bf6d49bd 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -249,15 +249,24 @@ static _Noreturn void | |||
| 249 | json_parse_error (const json_error_t *error) | 249 | json_parse_error (const json_error_t *error) |
| 250 | { | 250 | { |
| 251 | Lisp_Object symbol; | 251 | Lisp_Object symbol; |
| 252 | /* FIXME: Upstream Jansson should have a way to return error codes | 252 | #if JANSSON_VERSION_HEX >= 0x020B00 |
| 253 | without parsing the error messages. See | 253 | switch (json_error_code (error)) |
| 254 | https://github.com/akheron/jansson/issues/352. */ | 254 | { |
| 255 | case json_error_premature_end_of_input: | ||
| 256 | symbol = Qjson_end_of_file; | ||
| 257 | case json_error_end_of_input_expected: | ||
| 258 | symbol = Qjson_trailing_content; | ||
| 259 | default: | ||
| 260 | symbol = Qjson_parse_error; | ||
| 261 | } | ||
| 262 | #else | ||
| 255 | if (json_has_suffix (error->text, "expected near end of file")) | 263 | if (json_has_suffix (error->text, "expected near end of file")) |
| 256 | symbol = Qjson_end_of_file; | 264 | symbol = Qjson_end_of_file; |
| 257 | else if (json_has_prefix (error->text, "end of file expected")) | 265 | else if (json_has_prefix (error->text, "end of file expected")) |
| 258 | symbol = Qjson_trailing_content; | 266 | symbol = Qjson_trailing_content; |
| 259 | else | 267 | else |
| 260 | symbol = Qjson_parse_error; | 268 | symbol = Qjson_parse_error; |
| 269 | #endif | ||
| 261 | xsignal (symbol, | 270 | xsignal (symbol, |
| 262 | list5 (json_build_string (error->text), | 271 | list5 (json_build_string (error->text), |
| 263 | json_build_string (error->source), make_natnum (error->line), | 272 | json_build_string (error->source), make_natnum (error->line), |