libplugin: new helper method for passing a raw error

Makes it easier to stash an error and then return it after another
RPC call has been made.
This commit is contained in:
lisa neigut 2019-08-27 22:38:12 -05:00 committed by Rusty Russell
parent f784863603
commit 2fe490294e
2 changed files with 12 additions and 0 deletions

View File

@ -263,6 +263,13 @@ struct command_result *command_done_err(struct command *cmd,
return end_cmd(cmd);
}
struct command_result *command_err_raw(struct command *cmd,
const char *json_str)
{
return command_done_raw(cmd, "error",
json_str, strlen(json_str));
}
struct command_result *timer_complete(void)
{
assert(in_timer > 0);

View File

@ -62,6 +62,11 @@ command_done_err(struct command *cmd,
const char *errmsg,
const struct json_out *data);
/* Send a raw error response. Useful for forwarding a previous
* error after cleanup */
struct command_result *command_err_raw(struct command *cmd,
const char *json_str);
/* This command is finished, here's the result object; @cmd cannot be NULL. */
struct command_result *WARN_UNUSED_RESULT
command_success(struct command *cmd, const struct json_out *result);