lightning-cli: give error message when lightningd produces non-object response.

Nicer than assert() failing without showing the response.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-01-22 06:41:49 +10:30
parent 0dbbd81430
commit a5e08e7f79

View File

@ -140,6 +140,10 @@ int main(int argc, char *argv[])
errx(ERROR_TALKING_TO_LIGHTNINGD,
"Malformed response '%s'", resp);
if (toks->type != JSMN_OBJECT)
errx(ERROR_TALKING_TO_LIGHTNINGD,
"Non-object response '%s'", resp);
result = json_get_member(resp, toks, "result");
if (!result)
errx(ERROR_TALKING_TO_LIGHTNINGD,