aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2019-11-05 23:37:30 +0000
committerJoão Távora2019-11-05 23:37:53 +0000
commita8dbb7cc865f227a39708df3fe8d24e6f52b6e28 (patch)
tree959d62eb6ea6e11d2660a31b1f4f666b46e62015
parentfbcfee3ae492922abc34e62381354c7d8b989fea (diff)
downloademacs-a8dbb7cc865f227a39708df3fe8d24e6f52b6e28.tar.gz
emacs-a8dbb7cc865f227a39708df3fe8d24e6f52b6e28.zip
Follow JSONRPC spec by not sending :result field on errors
Also don't send :error field on non-errors. * lisp/jsonrpc.el (jsonrpc--reply): Don't send :result and :error if none supplied. (Version): Bump to 1.0.8
-rw-r--r--lisp/jsonrpc.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 41cd84627be..abab445fe5c 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -5,7 +5,7 @@
5;; Author: João Távora <joaotavora@gmail.com> 5;; Author: João Távora <joaotavora@gmail.com>
6;; Keywords: processes, languages, extensions 6;; Keywords: processes, languages, extensions
7;; Package-Requires: ((emacs "25.2")) 7;; Package-Requires: ((emacs "25.2"))
8;; Version: 1.0.7 8;; Version: 1.0.8
9 9
10;; This is an Elpa :core package. Don't use functionality that is not 10;; This is an Elpa :core package. Don't use functionality that is not
11;; compatible with Emacs 25.2. 11;; compatible with Emacs 25.2.
@@ -460,9 +460,13 @@ With optional CLEANUP, kill any associated buffers."
460 (json-null nil)) 460 (json-null nil))
461 (json-encode object))))) 461 (json-encode object)))))
462 462
463(cl-defun jsonrpc--reply (connection id &key (result nil result-supplied-p) error) 463(cl-defun jsonrpc--reply
464 (connection id &key (result nil result-supplied-p) (error nil error-supplied-p))
464 "Reply to CONNECTION's request ID with RESULT or ERROR." 465 "Reply to CONNECTION's request ID with RESULT or ERROR."
465 (jsonrpc-connection-send connection :id id :result result :error error)) 466 (apply #'jsonrpc-connection-send connection
467 `(:id ,id
468 ,@(and result-supplied-p `(:result ,result))
469 ,@(and error-supplied-p `(:error ,error)))))
466 470
467(defun jsonrpc--call-deferred (connection) 471(defun jsonrpc--call-deferred (connection)
468 "Call CONNECTION's deferred actions, who may again defer themselves." 472 "Call CONNECTION's deferred actions, who may again defer themselves."