connectd: add own err codes instead of generic -1

Make it possible for connectd to send an error code to lightningd in
addition to the error message. Introduce two new error codes, replacing
the catch-all -1.

This change, together with
https://github.com/ElementsProject/lightning/pull/3395
will implement https://github.com/ElementsProject/lightning/issues/3366

Changelog-Changed: The `connect` command now returns its own error codes instead of a generic -1.
This commit is contained in:
Vasil Dimov
2020-01-05 18:17:25 +01:00
committed by Christian Decker
parent 3cf91b23b9
commit fc75d8a9e6
6 changed files with 71 additions and 20 deletions

View File

@@ -40,14 +40,41 @@ another node\. Once the peer is connected a channel can be opened with
On success the peer \fIid\fR is returned\.
.SH ERRORS
The following error codes may occur:
On failure, one of the following errors will be returned:
.IP \[bu]
-1: Catchall nonspecific error\. This may occur if the host is not
valid or there are problems communicating with the peer\. \fBconnect\fR
will make up to 10 attempts to connect to the peer before giving up\.
.nf
.RS
{ "code" : 400, "message" : "Unable to connect, no address known for peer" }
.RE
.fi
If some addresses are known but connecting to all of them failed, the message
will contain details about the failures:
.nf
.RS
{ "code" : 401, "message" : "..." }
.RE
.fi
If the given parameters are wrong:
.nf
.RS
{ "code" : -32602, "message" : "..." }
.RE
.fi
.SH AUTHOR
Rusty Russell \fI<rusty@rustcorp.com.au\fR> is mainly responsible\.

View File

@@ -37,10 +37,21 @@ RETURN VALUE
On success the peer *id* is returned.
The following error codes may occur:
- -1: Catchall nonspecific error. This may occur if the host is not
valid or there are problems communicating with the peer. **connect**
will make up to 10 attempts to connect to the peer before giving up.
ERRORS
------
On failure, one of the following errors will be returned:
{ "code" : 400, "message" : "Unable to connect, no address known for peer" }
If some addresses are known but connecting to all of them failed, the message
will contain details about the failures:
{ "code" : 401, "message" : "..." }
If the given parameters are wrong:
{ "code" : -32602, "message" : "..." }
AUTHOR
------