jsonrpc: make error codes an enum.

This allows GDB to print values, but also allows us to use them in
'case' statements.  This wasn't allowed before because they're not
constant terms.

This also made it clear there's a clash between two error codes,
so move one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: Error code from bcli plugin changed from 400 to 500.
This commit is contained in:
Rusty Russell
2022-09-18 09:50:50 +09:30
parent 7fa1364645
commit 2da5244e83
31 changed files with 152 additions and 152 deletions

View File

@@ -389,14 +389,14 @@ command_success(struct command *cmd, const struct json_out *result)
}
struct command_result *command_done_err(struct command *cmd,
errcode_t code,
enum jsonrpc_errcode code,
const char *errmsg,
const struct json_out *data)
{
struct json_stream *js = jsonrpc_stream_start(cmd);
json_object_start(js, "error");
json_add_errcode(js, "code", code);
json_add_jsonrpc_errcode(js, "code", code);
json_add_string(js, "message", errmsg);
if (data)
@@ -442,7 +442,7 @@ struct command_result *forward_result(struct command *cmd,
/* Called by param() directly if it's malformed. */
struct command_result *command_fail(struct command *cmd,
errcode_t code, const char *fmt, ...)
enum jsonrpc_errcode code, const char *fmt, ...)
{
va_list ap;
struct command_result *res;