What is the standard approach to returning a JSON RPC response when there is only partial failure? It appears that both 'result' and 'error' cannot both be set.
We have a case where a server is aggregating results across several sites running the same API. The reason for the aggregation is due to the Same-Origin Policy. Each site may respond with either a result or an error. If some respond with a result and others with an error, then what does the aggregation server return as the complete response to the original caller?
a =(method)=> b
b =(method)=> c
b =(method)=> d
b <=(error)== c
b <=(result)= d
a <=(??????)= b
Is it best to simply return two responses (one with any errors and no 'id' and one with the results and an 'id' suggesting this is the last response)?
答案 0 :(得分:0)
服务器职责是聚合并返回可能包含错误的结果。这是您的客户所期望的。
--> {"jsonrpc": "2.0", "method": "getResults", "id": 1}
<-- {"jsonrpc": "2.0", "result": [ "success", "error" ], "id": 1}
如果服务器本身因任何意外原因无法处理请求,您应该返回错误。