mirror of https://codeberg.org/cage/tinmop/
- [JSONRPC] added optional data field to error response.
This commit is contained in:
parent
7fc90b428c
commit
c01188e0db
|
@ -109,14 +109,6 @@
|
|||
(cons "cached" cached)
|
||||
(cons "iri" iri)))
|
||||
|
||||
(a:define-constant +gemini-response-error-code+ -32011 :test #'=)
|
||||
|
||||
(defun make-gemini-response-error (message)
|
||||
(rpc:make-response nil
|
||||
nil
|
||||
:error-object (rpc::make-response-error +gemini-response-error-code+
|
||||
message)))
|
||||
|
||||
(defun %gemini-request (url &key
|
||||
(certificate nil)
|
||||
(certificate-key nil)
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
(define-constant +key-error-message+ "message" :test #'string=)
|
||||
|
||||
(define-constant +key-error-data+ "data" :test #'string=)
|
||||
|
||||
(define-constant +key-result+ "result" :test #'string=)
|
||||
|
||||
(define-constant +error-reserved-min+ -32099 :test #'=)
|
||||
|
@ -45,9 +47,10 @@
|
|||
(cl-ppcre:scan +error-reserved-method-name+ n))
|
||||
|
||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(defun make-response-error (code message)
|
||||
(defun make-response-error (code message &optional (data nil))
|
||||
(list (cons +key-error-code+ code)
|
||||
(cons +key-error-message+ message)))
|
||||
(cons +key-error-message+ message)
|
||||
(cons +key-error-data+ data)))
|
||||
|
||||
(defun response-error-code (err)
|
||||
(cdar err))
|
||||
|
@ -78,8 +81,10 @@
|
|||
(defun make-internal-error-message (msg)
|
||||
(make-response-error -32603 (format nil "Internal error: ~a" msg)))
|
||||
|
||||
(defun make-failed-function-call-error-message (msg)
|
||||
(make-response-error -32001 (format nil "Failed function call: ~a" msg)))
|
||||
(defun make-failed-function-call-error-message (msg &optional (data nil))
|
||||
(make-response-error -32001
|
||||
(format nil "Failed function call: ~a" msg)
|
||||
data))
|
||||
|
||||
(defclass function-param ()
|
||||
((name
|
||||
|
@ -415,10 +420,13 @@
|
|||
(make-response nil
|
||||
nil
|
||||
:error-object (make-internal-error-message (format nil "~a" e))))
|
||||
(make-failed-function-error (e id)
|
||||
(make-failed-function-error (e id &optional (data nil))
|
||||
(make-response nil
|
||||
id
|
||||
:error-object (make-failed-function-call-error-message (format nil "~a" e)))))
|
||||
:error-object (make-failed-function-call-error-message (format nil
|
||||
"~a"
|
||||
e)
|
||||
data))))
|
||||
(handler-case
|
||||
(multiple-value-bind (method id params)
|
||||
(displace-single-request request)
|
||||
|
@ -434,7 +442,7 @@
|
|||
(make-rpc-error e))
|
||||
(error (e)
|
||||
(maybe-log-message (format nil "jsonrpc request failed: ~a" e))
|
||||
(make-failed-function-error e id))))
|
||||
(make-failed-function-error e id nil))))
|
||||
(json-rpc-error (e)
|
||||
(make-rpc-error e))
|
||||
(error (e)
|
||||
|
|
Loading…
Reference in New Issue