Browse Source

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.
travis-debug
lisa neigut 5 years ago
committed by Rusty Russell
parent
commit
2fe490294e
  1. 7
      plugins/libplugin.c
  2. 5
      plugins/libplugin.h

7
plugins/libplugin.c

@ -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);

5
plugins/libplugin.h

@ -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);

Loading…
Cancel
Save