From b80c4b43dd47bf44c45bdab3e6f8b4b66a461074 Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Thu, 13 Feb 2020 19:57:44 -0500 Subject: Add an appropriate error for reading bad JSON arrays * lisp/json.el (json-array-format): New error. (json-read-array): Use it. --- lisp/json.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/json.el b/lisp/json.el index 18d7fda8822..055f3f5be11 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -227,6 +227,7 @@ Unlike `reverse', this keeps the property-value pairs intact." (define-error 'json-string-format "Bad string format" 'json-error) (define-error 'json-key-format "Bad JSON object key" 'json-error) (define-error 'json-object-format "Bad JSON object" 'json-error) +(define-error 'json-array-format "Bad JSON array" 'json-error) (define-error 'json-end-of-file "End of file while parsing JSON" '(end-of-file json-error)) @@ -640,7 +641,7 @@ become JSON objects." (when (/= (json-peek) ?\]) (if (= (json-peek) ?,) (json-advance) - (signal 'json-error (list 'bleah))))) + (signal 'json-array-format (list ?, (json-peek)))))) ;; Skip over the "]" (json-advance) (pcase json-array-type -- cgit v1.2.1