From: Mark Oteiza Date: Fri, 14 Feb 2020 00:57:44 +0000 (-0500) Subject: Add an appropriate error for reading bad JSON arrays X-Git-Tag: emacs-28.0.90~7888 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b80c4b43dd47bf44c45bdab3e6f8b4b66a461074;p=emacs.git Add an appropriate error for reading bad JSON arrays * lisp/json.el (json-array-format): New error. (json-read-array): Use it. --- 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