| 591 | } |
| 592 | |
| 593 | struct command_result *command_done_err(struct command *cmd, |
| 594 | enum jsonrpc_errcode code, |
| 595 | const char *errmsg, |
| 596 | const struct json_out *data) |
| 597 | { |
| 598 | struct json_stream *js = jsonrpc_stream_start(cmd); |
| 599 | assert(cmd->type == COMMAND_TYPE_NORMAL |
| 600 | || cmd->type == COMMAND_TYPE_CHECK); |
| 601 | |
| 602 | json_object_start(js, "error"); |
| 603 | json_add_jsonrpc_errcode(js, "code", code); |
| 604 | json_add_string(js, "message", errmsg); |
| 605 | |
| 606 | if (data) |
| 607 | json_out_add_splice(js->jout, "data", data); |
| 608 | json_object_end(js); |
| 609 | |
| 610 | return command_complete(cmd, js); |
| 611 | } |
| 612 | |
| 613 | struct command_result *command_err_raw(struct command *cmd, |
| 614 | const char *json_str) |
no test coverage detected