Skip to content

Expose error codes#60

Merged
balthazar merged 3 commits intoccxt:masterfrom
bennycode:patch-3
Mar 6, 2018
Merged

Expose error codes#60
balthazar merged 3 commits intoccxt:masterfrom
bennycode:patch-3

Conversation

@bennycode
Copy link
Copy Markdown
Contributor

This PR solves /issues/58 - I am adding the code from the error payload to the error object, so that it can be checked.

Test code:

const Binance = require('./dist/index').default

const client = Binance({
  apiKey,
  apiSecret,
})

const order = {'symbol': 'TRXETH', 'side': 'SELL', 'type': 'LIMIT', 'quantity': '-1337', 'price': '1.00000000'}

client.order(order).catch(error => console.log('Error code', error.code))

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 6, 2018

Coverage Status

Coverage decreased (-23.8%) to 69.231% when pulling 796721c on bennyn:patch-3 into 6647d6d on HyperCubeProject:master.

@balthazar
Copy link
Copy Markdown
Collaborator

Perfect! I'm wondering if it would be interesting to expose some error types tight to these codes or would that not be helpful at all?

@balthazar balthazar merged commit 9625e46 into ccxt:master Mar 6, 2018
@bennycode
Copy link
Copy Markdown
Contributor Author

That's a good idea! We can create enums for the error codes, so that checks can be done like this:

t.is(e.code, BinanceError.ILLEGAL_CHARS)

We can use the same identifiers as listed in the Error codes for Binance document, which are BinanceError.UNKNOWN, BinanceError.DISCONNECTED, BinanceError.UNAUTHORIZED, BinanceError.TOO_MANY_REQUESTS, BinanceError.UNEXPECTED_RESP, ...

@bennycode bennycode mentioned this pull request Mar 7, 2018
@bennycode bennycode deleted the patch-3 branch March 7, 2018 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants