[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 489182d 24/69: New jsonrpc-error error type
From: |
João Távora |
Subject: |
[elpa] externals/eglot 489182d 24/69: New jsonrpc-error error type |
Date: |
Fri, 22 Jun 2018 11:54:57 -0400 (EDT) |
branch: externals/eglot
commit 489182d53e11c98b859fe8baaf8f2b3c04c39fb5
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
New jsonrpc-error error type
* jsonrpc.el (usage example): update to use jsonrpc-error.
(jsonrpc-error): New error type.
(jsonrpc-error, jsonrpc-request): Signal it.
---
jsonrpc.el | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/jsonrpc.el b/jsonrpc.el
index cda035e..f801931 100644
--- a/jsonrpc.el
+++ b/jsonrpc.el
@@ -76,13 +76,15 @@
;; (message "Sadly, server reports %s: %s"
;; code message)))
;;
+;;;; Usage example:
+;;
;; Finally, here's an example Emacs JSONRPC server that offers a (very
;; small) subset of Elisp for remote calling:
;;
-;; (defvar server) (defvar server-endpoint)
+;; (defvar server-server) (defvar server-endpoint)
;; (defvar server-allowed-functions '(+ - * / vconcat append sit-for))
;;
-;; (setq server
+;; (setq server-server
;; (make-network-process
;; :name "Emacs RPC server" :server t :host "localhost" :service 9393
;; :log (lambda (_server client _message)
@@ -90,9 +92,9 @@
;; (process-name client) client
;; (lambda (proc method id params)
;; (unless (memq method server-allowed-functions)
-;; (signal 'error `((jsonrpc-error-message
-;; . "Sorry, this isn't allowed")
-;; (jsonrpc-error-code . 32601))))
+;; (signal 'jsonrpc-error `((jsonrpc-error-message
+;; . "Sorry, this isn't
allowed")
+;; (jsonrpc-error-code .
32601))))
;; (jsonrpc-reply proc id :result
;; (apply method (append params nil))))))))
@@ -135,12 +137,15 @@
(or (jsonrpc-current-process)
(jsonrpc-error "No current JSON-RPC process")))
+(define-error 'jsonrpc-error "jsonrpc-error")
+
(defun jsonrpc-error (format &rest args)
"Error out with FORMAT and ARGS.
If invoked inside a dispatcher function, this function is suitable
for replying to the remote endpoint with a -32603 error code and
FORMAT as the message."
- (signal 'error (format "[jsonrpc] %s" (apply #'format format args))))
+ (signal 'error
+ (list (apply #'format-message (concat "[jsonrpc] " format) args))))
(defun jsonrpc-message (format &rest args)
"Message out with FORMAT with ARGS."
@@ -618,9 +623,9 @@ DEFERRED is passed to `jsonrpc-async-request', which see."
(when id (remhash id (jsonrpc--request-continuations proc)))
(when timer (cancel-timer timer))))))
(when (eq 'error (car retval))
- (signal 'error
+ (signal 'jsonrpc-error
(cons
- (format "[jsonrpc] jsonrpc-request (%s) failed:" (car
id-and-timer))
+ (format "request id=%s failed:" (car id-and-timer))
(cdr retval))))
(cadr retval)))
- [elpa] externals/eglot 078a1a6 13/69: Add full "Commentary" section to jrpc.el, (continued)
- [elpa] externals/eglot 078a1a6 13/69: Add full "Commentary" section to jrpc.el, João Távora, 2018/06/22
- [elpa] externals/eglot 2f1d76d 03/69: Proper server shutdown when jrpc.el is used, João Távora, 2018/06/22
- [elpa] externals/eglot a2aa1ed 19/69: Robustify timer handling for jrpc-async-request, João Távora, 2018/06/22
- [elpa] externals/eglot 7769c07 16/69: Send message, then establish continuations, João Távora, 2018/06/22
- [elpa] externals/eglot 7f2e894 11/69: Merge branch 'master' into jsonrpc-refactor (using good ol' git merge), João Távora, 2018/06/22
- [elpa] externals/eglot e5ba4f6 18/69: Automatically reply with error if dispatcher doesn't, João Távora, 2018/06/22
- [elpa] externals/eglot 33ae871 09/69: More flexible jrpc.el and improve eglot.el's doc, João Távora, 2018/06/22
- [elpa] externals/eglot 3265c1d 10/69: Simpler callback protocol for JSONRPC parameters and results, João Távora, 2018/06/22
- [elpa] externals/eglot e906d25 14/69: Overhaul JSON and JSRONRPC error handling, João Távora, 2018/06/22
- [elpa] externals/eglot 7cd94b9 12/69: Improve jrpc.el's doc (and change jrpc-request's protocol a tiny bit), João Távora, 2018/06/22
- [elpa] externals/eglot 489182d 24/69: New jsonrpc-error error type,
João Távora <=
- [elpa] externals/eglot 5cea412 20/69: Fix typos and phrasing in commentary and docstrings, João Távora, 2018/06/22
- [elpa] externals/eglot c30f0f3 23/69: Get rid of jsonrpc.el customization group and timeout, João Távora, 2018/06/22
- [elpa] externals/eglot 5e8fe4c 26/69: Add jsonrpc-tests.el, João Távora, 2018/06/22
- [elpa] externals/eglot 05ff697 29/69: Document current API breaches a bit, João Távora, 2018/06/22
- [elpa] externals/eglot 258e3b0 07/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 4bbf810 25/69: Don't return implementation details in jsonrpc-async-request, João Távora, 2018/06/22
- [elpa] externals/eglot 5874af9 32/69: Fix deferred actions (forgot the crucial non-local exit), João Távora, 2018/06/22
- [elpa] externals/eglot 481f16e 33/69: * eglot.el (eglot-eldoc-function): Remove spurious log message, João Távora, 2018/06/22
- [elpa] externals/eglot c43dff4 35/69: On request timeout, clear it from the deferred actions, João Távora, 2018/06/22
- [elpa] externals/eglot 870c60a 04/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22