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 response handling #50

Merged
merged 1 commit into from
Nov 27, 2017

Conversation

ruimarinho
Copy link
Owner

  • Better error handling for both RPC and REST calls.
    • Handle text/html and text/plain differences from both request types correctly.
    • Proxy response errors as error messages for easier debugging.
    • Add a test for batched requests where one of the request fails.
    • Handle errors in binary-encoded requests.
  • Parse REST responses with JSONBigInt to avoid losing precision. This means that some of the response values will now be strings (e.g. the network difficulty on getDifficulty()).

Copy link
Collaborator

@joaopaulofonseca joaopaulofonseca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of small nits. Other than that, LGTM.


const [newAddressError, addressValidation] = await new Client(config.bitcoind).command(batch);

addressValidation.should.have.properties('address', 'isvalid', 'ismine', 'scriptPubKey');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort list.

src/parser.js Outdated
throw new RpcError(response.statusCode, response.statusMessage);
}

function getRpcBody(body, { headers = false, response } = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the method description as well.

@ruimarinho ruimarinho force-pushed the enhancement/improved-response-handling branch from 7341c87 to 0f2ca1a Compare November 27, 2017 11:28
* Better error handling for both RPC and REST calls.
  * Handle `text/html` and `text/plain` differences from both request
    types correctly.
  * Proxy response errors as error messages for easier debugging.
  * Add a test for batched requests where one of the request fails.
  * Handle errors in binary-encoded requests.
* Parse REST responses with JSONBigInt to avoid losing precision. This
  means that some of the response values will now be strings (e.g.
  the network difficulty on `getDifficulty()`).
@ruimarinho ruimarinho force-pushed the enhancement/improved-response-handling branch from 0f2ca1a to 093d562 Compare November 27, 2017 11:45
@joaopaulofonseca joaopaulofonseca merged commit 6d558a4 into master Nov 27, 2017
@joaopaulofonseca joaopaulofonseca deleted the enhancement/improved-response-handling branch November 27, 2017 11:50
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