1
0
Fork 0

- [JSON-RPC] added the request (that triggered the error) to the data field of an error response.

This commit is contained in:
cage 2023-02-04 11:31:36 +01:00
parent ba5ddb6d7a
commit 90ae6193e8
1 changed files with 12 additions and 10 deletions

View File

@ -78,8 +78,8 @@
(define-error-code unsupported-protocol -32098 "Only protocol version 2.0 is supported"
:customp t)
(defun make-internal-error-message (msg)
(make-response-error -32603 (format nil "Internal error: ~a" msg)))
(defun make-internal-error-message (msg data)
(make-response-error -32603 (format nil "Internal error: ~a" msg) data))
(defun make-failed-function-call-error-message (msg &optional (data nil))
(make-response-error -32001
@ -414,18 +414,20 @@
(misc:dbg m))
(defun elaborate-single-request (request)
(flet ((make-rpc-error (e id)
(flet ((make-rpc-error (e id &optional (data nil))
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
(make-response nil
(or (transaction-id e)
id)
:error-object (make-response-error (or (code e)
(response-error-code +error-invalid-request+))
(text e))))
(make-internal-error (e)
(text e)
data)))
(make-internal-error (e &optional (data nil))
(make-response nil
nil
:error-object (make-internal-error-message (format nil "~a" e))))
:error-object (make-internal-error-message (format nil "~a" e)
data)))
(make-failed-function-error (e id &optional (data nil))
(make-response nil
id
@ -448,15 +450,15 @@
;; does not care about an answer)
(make-response elaborated id :error-object nil)))
(json-rpc-error (e)
(make-rpc-error e id))
(make-rpc-error e id request))
(error (e)
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
(make-failed-function-error e id nil))))
(make-failed-function-error e id request))))
(json-rpc-error (e)
(make-rpc-error e nil))
(make-rpc-error e nil request))
(error (e)
(maybe-log-message (format nil "jsonrpc request failed with internal error!: ~a" e))
(make-internal-error e)))))
(make-internal-error e request)))))
(defun likely-not-batch-p (request)
(and (every (lambda (a) (and (consp a)