原始文献 / 论坛帖 / Re: HTTP status codes from the JSON-RPC api
Re: HTTP status codes from the JSON-RPC api
Bitcointalk · 2010-09-06 21:21:21 UTC
这已纳入 SVN rev 147。
这更标准,虽然 json-rpc 1.0 没规定错误对象的格式,但它规定了错误是对象而不是字符串或其他值,所以我们得改成正确的。code/message 成员在后来的 json-rpc 规范里成了标准。
如果你的代码检查错误并期望是个字符串,你得改。出错时,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.
