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)
|
||||
(make-response-error -32603 (format nil "Internal error: ~a" msg)))
|
||||
|
||||
(defun make-failed-request-error-message (msg)
|
||||
(make-response-error -32001 (format nil "failed request: ~a" msg)))
|
||||
(defun make-failed-function-call-error-message (msg)
|
||||
(make-response-error -32001 (format nil "Failed functino call: ~a" msg)))
|
||||
|
||||
(defclass function-param ()
|
||||
((name
|
||||
|
@ -380,14 +380,17 @@
|
|||
(cond
|
||||
((null protocol-version)
|
||||
(error 'json-rpc-error
|
||||
:transaction-id id
|
||||
:code (response-error-code +error-invalid-request+)
|
||||
:text (response-error-message +error-invalid-request+)))
|
||||
((not (supported-version-p protocol-version))
|
||||
(error 'json-rpc-error
|
||||
:transaction-id id
|
||||
:code (response-error-code +error-unsupported-protocol+)
|
||||
:text (response-error-message +error-unsupported-protocol+)))
|
||||
((not (listp params))
|
||||
(error 'json-rpc-error
|
||||
:transaction-id id
|
||||
:code (response-error-code +error-invalid-request+)
|
||||
:text (response-error-message +error-invalid-request+)))
|
||||
(t
|
||||
|
@ -399,6 +402,17 @@
|
|||
(misc:dbg m))
|
||||
|
||||
(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
|
||||
(multiple-value-bind (method id params)
|
||||
(displace-single-request request)
|
||||
|
@ -411,22 +425,15 @@
|
|||
;; does not care about an answer)
|
||||
(make-response elaborated id :error-object nil)))
|
||||
(json-rpc-error (e)
|
||||
(make-response nil
|
||||
nil
|
||||
:error-object
|
||||
(make-response-error (or (code e)
|
||||
(response-error-code +error-invalid-request+))
|
||||
(text e))))
|
||||
(make-rpc-error e))
|
||||
(error (e)
|
||||
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
|
||||
(make-response nil
|
||||
id
|
||||
:error-object (make-failed-request-error-message (format nil "~a" e))))))
|
||||
(make-internal-error e))))
|
||||
(json-rpc-error (e)
|
||||
(make-rpc-error e))
|
||||
(error (e)
|
||||
(maybe-log-message (format nil "jsonrpc request failed with internal error!: ~a" e))
|
||||
(make-response nil
|
||||
nil
|
||||
:error-object (make-internal-error-message (format nil "~a" e))))))
|
||||
(make-internal-error e)))))
|
||||
|
||||
(defun likely-not-batch-p (request)
|
||||
(and (every (lambda (a) (and (consp a)
|
||||
|
|
Loading…
Reference in New Issue