mirror of https://codeberg.org/cage/tinmop/
- [rpc] fixed error responses, tests passed again.
This commit is contained in:
parent
cbb447a84e
commit
5052c21fe3
|
@ -78,8 +78,8 @@
|
||||||
(defun make-internal-error-message (msg)
|
(defun make-internal-error-message (msg)
|
||||||
(make-response-error -32603 (format nil "Internal error: ~a" msg)))
|
(make-response-error -32603 (format nil "Internal error: ~a" msg)))
|
||||||
|
|
||||||
(defun make-failed-request-error-message (msg)
|
(defun make-failed-function-call-error-message (msg)
|
||||||
(make-response-error -32001 (format nil "failed request: ~a" msg)))
|
(make-response-error -32001 (format nil "Failed functino call: ~a" msg)))
|
||||||
|
|
||||||
(defclass function-param ()
|
(defclass function-param ()
|
||||||
((name
|
((name
|
||||||
|
@ -380,14 +380,17 @@
|
||||||
(cond
|
(cond
|
||||||
((null protocol-version)
|
((null protocol-version)
|
||||||
(error 'json-rpc-error
|
(error 'json-rpc-error
|
||||||
|
:transaction-id id
|
||||||
:code (response-error-code +error-invalid-request+)
|
:code (response-error-code +error-invalid-request+)
|
||||||
:text (response-error-message +error-invalid-request+)))
|
:text (response-error-message +error-invalid-request+)))
|
||||||
((not (supported-version-p protocol-version))
|
((not (supported-version-p protocol-version))
|
||||||
(error 'json-rpc-error
|
(error 'json-rpc-error
|
||||||
|
:transaction-id id
|
||||||
:code (response-error-code +error-unsupported-protocol+)
|
:code (response-error-code +error-unsupported-protocol+)
|
||||||
:text (response-error-message +error-unsupported-protocol+)))
|
:text (response-error-message +error-unsupported-protocol+)))
|
||||||
((not (listp params))
|
((not (listp params))
|
||||||
(error 'json-rpc-error
|
(error 'json-rpc-error
|
||||||
|
:transaction-id id
|
||||||
:code (response-error-code +error-invalid-request+)
|
:code (response-error-code +error-invalid-request+)
|
||||||
:text (response-error-message +error-invalid-request+)))
|
:text (response-error-message +error-invalid-request+)))
|
||||||
(t
|
(t
|
||||||
|
@ -399,6 +402,17 @@
|
||||||
(misc:dbg m))
|
(misc:dbg m))
|
||||||
|
|
||||||
(defun elaborate-single-request (request)
|
(defun elaborate-single-request (request)
|
||||||
|
(flet ((make-rpc-error (e)
|
||||||
|
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
|
||||||
|
(make-response nil
|
||||||
|
(transaction-id e)
|
||||||
|
:error-object (make-response-error (or (code e)
|
||||||
|
(response-error-code +error-invalid-request+))
|
||||||
|
(text e))))
|
||||||
|
(make-internal-error (e)
|
||||||
|
(make-response nil
|
||||||
|
nil
|
||||||
|
:error-object (make-internal-error-message (format nil "~a" e)))))
|
||||||
(handler-case
|
(handler-case
|
||||||
(multiple-value-bind (method id params)
|
(multiple-value-bind (method id params)
|
||||||
(displace-single-request request)
|
(displace-single-request request)
|
||||||
|
@ -411,22 +425,15 @@
|
||||||
;; does not care about an answer)
|
;; does not care about an answer)
|
||||||
(make-response elaborated id :error-object nil)))
|
(make-response elaborated id :error-object nil)))
|
||||||
(json-rpc-error (e)
|
(json-rpc-error (e)
|
||||||
(make-response nil
|
(make-rpc-error e))
|
||||||
nil
|
|
||||||
:error-object
|
|
||||||
(make-response-error (or (code e)
|
|
||||||
(response-error-code +error-invalid-request+))
|
|
||||||
(text e))))
|
|
||||||
(error (e)
|
(error (e)
|
||||||
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
|
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
|
||||||
(make-response nil
|
(make-internal-error e))))
|
||||||
id
|
(json-rpc-error (e)
|
||||||
:error-object (make-failed-request-error-message (format nil "~a" e))))))
|
(make-rpc-error e))
|
||||||
(error (e)
|
(error (e)
|
||||||
(maybe-log-message (format nil "jsonrpc request failed with internal error!: ~a" e))
|
(maybe-log-message (format nil "jsonrpc request failed with internal error!: ~a" e))
|
||||||
(make-response nil
|
(make-internal-error e)))))
|
||||||
nil
|
|
||||||
:error-object (make-internal-error-message (format nil "~a" e))))))
|
|
||||||
|
|
||||||
(defun likely-not-batch-p (request)
|
(defun likely-not-batch-p (request)
|
||||||
(and (every (lambda (a) (and (consp a)
|
(and (every (lambda (a) (and (consp a)
|
||||||
|
|
Loading…
Reference in New Issue