mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 15:44:21 +01:00
Added error code parameter to command_fail
Until now, `command_fail()` reported an error code of -1 for all uses. This PR adds an `int code` parameter to `command_fail()`, requiring the caller to explicitly include the error code. This is part of #1464. The majority of the calls are used during parameter validation and their error code is now JSONRPC2_INVALID_PARAMS. The rest of the calls report an error code of LIGHTNINGD, which I defined to -1 in `jsonrpc_errors.h`. The intention here is that as we improve our error reporting, all occurenaces of LIGHTNINGD will go away and we can eventually remove it. I also converted calls to `command_fail_detailed()` that took a `NULL` `data` parameter to use the new `command_fail()`. The only difference from an end user perspecive is that bad input errors that used to be -1 will now be -32602 (JSONRPC2_INVALID_PARAMS).
This commit is contained in:
committed by
Christian Decker
parent
c20e859f05
commit
7f437715d5
@@ -20,6 +20,7 @@
|
||||
#include <lightningd/bitcoind.h>
|
||||
#include <lightningd/chaintopology.h>
|
||||
#include <lightningd/jsonrpc.h>
|
||||
#include <lightningd/jsonrpc_errors.h>
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <lightningd/log.h>
|
||||
#include <lightningd/options.h>
|
||||
@@ -1031,7 +1032,8 @@ static void json_listconfigs(struct command *cmd,
|
||||
json_object_end(response);
|
||||
|
||||
if (configtok && !found) {
|
||||
command_fail(cmd, "Unknown config option '%.*s'",
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Unknown config option '%.*s'",
|
||||
configtok->end - configtok->start,
|
||||
buffer + configtok->start);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user