Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message on missing rpc arguments #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dagurval
Copy link

Shows usage instead of assertion error.

Shows usage instead of assertion error
@dagurval
Copy link
Author

Before:

$ ./bin/bcoin-cli rpc
AssertionError [ERR_ASSERTION]: Assertion failed.
    at NodeClient.execute (/home/dagurval/bclient/node_modules/bcurl/lib/client.js:279:5)
    at NodeClient.execute (/home/dagurval/bclient/lib/node.js:44:18)
    at CLI.rpc (/home/dagurval/bclient/bin/bcoin-cli:159:34)
    at CLI.open (/home/dagurval/bclient/bin/bcoin-cli:195:20)
    at /home/dagurval/bclient/bin/bcoin-cli:221:13
    at Object.<anonymous> (/home/dagurval/bclient/bin/bcoin-cli:223:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

After:

$ ./bin/bcoin-cli rpc
Missing arguments
Commands:
  $ info: Get server info.
  $ broadcast [tx-hex]: Broadcast transaction.
  $ mempool: Get mempool snapshot.
  $ tx [hash/address]: View transactions.
  $ coin [hash+index/address]: View coins.
  $ block [hash/height]: View block.
  $ reset [height/hash]: Reset chain to desired block.
  $ rpc [command] [args]: Execute RPC command. (`bcoin-cli rpc help` for more)

@pinheadmz
Copy link
Member

This doesn't look quite right, a bad rpc call shouldn't list the REST API commands, it should list the possible rpc commands. Funny you should submit this today, there's ongoing discussion about the missing rpc help here: bcoin-org/bcoin#705

And an older approach not merged yet: bcoin-org/bcoin#550

@dagurval
Copy link
Author

I think that's a separate issue. This PR is for letting the user know that he used the cli interface incorrectly (missing arguments). It's an improvement over asserting.

I do agree that bcoin-cli rpc help could use improvement also.

@pinheadmz
Copy link
Member

I hear ya, but I think the best UX is providing the user with the list of possible arguments that could be missing. See #20 which in the case of a missing rpc method, will instead call rpc help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants