回复:JSON-RPC API 返回的 HTTP 状态码
原始发布页
打开来源页面查看 1 个交叉存档
这已包含在 SVN rev 147 中。
这种做法更符合标准。虽然 json-rpc 1.0 没有规定错误对象的格式,但它确实规定错误应当是对象,而不是字符串或其他值,因此我们需要修改这一点才是正确的。在后来的 json-rpc 规范中,code/message 成员已经成为标准。
如果你的代码会检查错误并期望得到字符串,就需要修改它。现在发生错误时,error 成员是对象而不是字符串。
SVN rev 147 中还包括: - 命令行 json-rpc 将错误码作为退出码返回。在 unix 上,退出码只能是 0-255,所以使用 abs(code)%256。 - 另一个帖子里讨论过的“backupwallet <destination>”命令。它会锁定钱包并复制,这样你就可以确保得到正确的副本。
英文原文
展开英文原文
This is in SVN rev 147.
This is more standard, and although json-rpc 1.0 didn't specify the format of error objects, it did specify that they would be objects not strings or other values, so we needed to change this to be correct. The code/message members have become standard in later json-rpc specs.
If you have code that checks the error and expects a string, you'll need to change it. When there is an error, the error member is now an object not a string.
Also in SVN rev 147: - The command line json-rpc returns the error code as its exit code. Exit codes can only be 0-255 on unix, so it's abs(code)%256. - The "backupwallet <destination>" command that was discussed in another thread. It locks the wallet and copies it, so you can be sure you get a correct copy.