diff options
| author | Mark Oteiza | 2020-02-13 19:57:44 -0500 |
|---|---|---|
| committer | Mark Oteiza | 2020-02-13 19:57:44 -0500 |
| commit | b80c4b43dd47bf44c45bdab3e6f8b4b66a461074 (patch) | |
| tree | 3a5d658c013d94df74dbfa89b4965b6719bd6b50 | |
| parent | 44298ea6aa006ed227e539b02279bd3fc11fd2a6 (diff) | |
| download | emacs-b80c4b43dd47bf44c45bdab3e6f8b4b66a461074.tar.gz emacs-b80c4b43dd47bf44c45bdab3e6f8b4b66a461074.zip | |
Add an appropriate error for reading bad JSON arrays
* lisp/json.el (json-array-format): New error.
(json-read-array): Use it.
| -rw-r--r-- | lisp/json.el | 3 |
1 files changed, 2 insertions, 1 deletions
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." | |||
| 227 | (define-error 'json-string-format "Bad string format" 'json-error) | 227 | (define-error 'json-string-format "Bad string format" 'json-error) |
| 228 | (define-error 'json-key-format "Bad JSON object key" 'json-error) | 228 | (define-error 'json-key-format "Bad JSON object key" 'json-error) |
| 229 | (define-error 'json-object-format "Bad JSON object" 'json-error) | 229 | (define-error 'json-object-format "Bad JSON object" 'json-error) |
| 230 | (define-error 'json-array-format "Bad JSON array" 'json-error) | ||
| 230 | (define-error 'json-end-of-file "End of file while parsing JSON" | 231 | (define-error 'json-end-of-file "End of file while parsing JSON" |
| 231 | '(end-of-file json-error)) | 232 | '(end-of-file json-error)) |
| 232 | 233 | ||
| @@ -640,7 +641,7 @@ become JSON objects." | |||
| 640 | (when (/= (json-peek) ?\]) | 641 | (when (/= (json-peek) ?\]) |
| 641 | (if (= (json-peek) ?,) | 642 | (if (= (json-peek) ?,) |
| 642 | (json-advance) | 643 | (json-advance) |
| 643 | (signal 'json-error (list 'bleah))))) | 644 | (signal 'json-array-format (list ?, (json-peek)))))) |
| 644 | ;; Skip over the "]" | 645 | ;; Skip over the "]" |
| 645 | (json-advance) | 646 | (json-advance) |
| 646 | (pcase json-array-type | 647 | (pcase json-array-type |