mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
7f437715d5
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).
37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
/* lightningd/jsonrpc_errors.h
|
|
* Lists error codes for JSON-RPC.
|
|
*/
|
|
#ifndef LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H
|
|
#define LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H
|
|
#include "config.h"
|
|
|
|
/* Standard errors defined by JSON-RPC 2.0 standard */
|
|
#define JSONRPC2_INVALID_REQUEST -32600
|
|
#define JSONRPC2_METHOD_NOT_FOUND -32601
|
|
#define JSONRPC2_INVALID_PARAMS -32602
|
|
|
|
/* Uncategorized error.
|
|
* FIXME: This should be replaced in all places
|
|
* with a specific error code, and then removed.
|
|
*/
|
|
#define LIGHTNINGD -1
|
|
|
|
/* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
|
|
#define PAY_IN_PROGRESS 200
|
|
#define PAY_RHASH_ALREADY_USED 201
|
|
#define PAY_UNPARSEABLE_ONION 202
|
|
#define PAY_DESTINATION_PERM_FAIL 203
|
|
#define PAY_TRY_OTHER_ROUTE 204
|
|
#define PAY_ROUTE_NOT_FOUND 205
|
|
#define PAY_ROUTE_TOO_EXPENSIVE 206
|
|
#define PAY_INVOICE_EXPIRED 207
|
|
#define PAY_NO_SUCH_PAYMENT 208
|
|
#define PAY_UNSPECIFIED_ERROR 209
|
|
#define PAY_STOPPED_RETRYING 210
|
|
|
|
/* Errors from `invoice` command */
|
|
#define INVOICE_LABEL_ALREADY_EXISTS 900
|
|
#define INVOICE_PREIMAGE_ALREADY_EXISTS 901
|
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_JSONRPC_ERRORS_H */
|