help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to test for native JSON support?


From: Philipp Stephani
Subject: Re: How to test for native JSON support?
Date: Tue, 4 May 2021 16:32:52 +0200

Am Di., 4. Mai 2021 um 16:31 Uhr schrieb Dmitry Gutov <dgutov@yandex.ru>:
>
> On 04.05.2021 17:01, Eli Zaretskii wrote:
>
> > Feel free to suggest a patch,
>
> Like this?
>
> diff --git a/src/json.c b/src/json.c
> index 3f1d27ad7f..ece057ae41 100644
> --- a/src/json.c
> +++ b/src/json.c
> @@ -596,8 +596,7 @@ DEFUN ("json-serialize", Fjson_serialize,
> Sjson_serialize, 1, MANY,
>       }
>     if (!json_initialized)
>       {
> -      message1 ("jansson library not found");
> -      return Qnil;
> +      Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
>       }
>   #endif
>
> @@ -707,8 +706,7 @@ DEFUN ("json-insert", Fjson_insert, Sjson_insert, 1,
> MANY,
>       }
>     if (!json_initialized)
>       {
> -      message1 ("jansson library not found");
> -      return Qnil;
> +      Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
>       }
>   #endif
>
> @@ -966,8 +964,7 @@ DEFUN ("json-parse-string", Fjson_parse_string,
> Sjson_parse_string, 1, MANY,
>       }
>     if (!json_initialized)
>       {
> -      message1 ("jansson library not found");
> -      return Qnil;
> +      Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
>       }
>   #endif
>
> @@ -1065,8 +1062,7 @@ DEFUN ("json-parse-buffer", Fjson_parse_buffer,
> Sjson_parse_buffer,
>       }
>     if (!json_initialized)
>       {
> -      message1 ("jansson library not found");
> -      return Qnil;
> +      Fsignal (Qerror, list1 (build_unibyte_string ("jansson library
> not found")));
>       }
>   #endif
>

Can you make this signal a specific error symbol so that callers can
catch the error and react accordingly, e.g. by falling back to
json.el?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]