JSON-RPC API 返回的 HTTP 状态码

中本聪SN-2683

这在 SVN rev 147 里。

This is in SVN rev 147.

这样更标准。虽然 json-rpc 1.0 没有规定错误对象的格式,但它规定了错误应当是对象而不是字符串或其他值,因此我们得改过来才算正确。code/message 成员在后来的 json-rpc 规范里已经成为标准。

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.

如果你的代码在检查 error 时假定它是字符串,就需要修改。出错时,error 成员现在是对象而不是字符串。

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.

SVN rev 147 里尚有:

  • 命令行 json-rpc 把错误码作为退出码返回。unix 上退出码只能是 0-255,因此是 abs(code)%256。
  • 另一个帖子里讨论过的 "backupwallet " 命令。它会锁定钱包并拷贝,因此你能确定拿到的是正确的副本。

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 " command that was discussed in another thread. It locks the wallet and copies it, so you can be sure you get a correct copy.
上下文
译文校对、修订与纠错

当前版本尚未建立逐条校对状态记录。来源核验、历史审校与当前译文校对是不同事项。

查看历史审校与代表修订 →

译文内容版本:bf55eefbbb90。用于比对文本,不代表校对等级或更新时间。

准备纠错说明

请填写对应原文、现译文、建议译法和理由。复制后通过你联系本站作者的渠道提交;此处不会自动发送。

来源
英文原标题

HTTP status codes from the JSON-RPC api

Bitcointalk · 原始链接 ↗ 记录编号 SN-2683

阅读字号

选择适合你的字号,之后阅读会继续使用。