| 601 | } |
| 602 | |
| 603 | struct command_result *command_done_err(struct command *cmd, |
| 604 | enum jsonrpc_errcode code, |
| 605 | const char *errmsg, |
| 606 | const struct json_out *data) |
| 607 | { |
| 608 | struct json_stream *js = jsonrpc_stream_start(cmd); |
| 609 | assert(cmd->type == COMMAND_TYPE_NORMAL |
| 610 | || cmd->type == COMMAND_TYPE_CHECK); |
| 611 | |
| 612 | json_object_start(js, "error"); |
| 613 | json_add_jsonrpc_errcode(js, "code", code); |
| 614 | json_add_string(js, "message", errmsg); |
| 615 | |
| 616 | if (data) |
| 617 | json_out_add_splice(js->jout, "data", data); |
| 618 | json_object_end(js); |
| 619 | |
| 620 | return command_complete(cmd, js); |
| 621 | } |
| 622 | |
| 623 | struct command_result *command_err_raw(struct command *cmd, |
| 624 | const char *json_str) |
no test coverage detected