Skip to content

Commit

Permalink
add error_code for luno API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dutu committed May 20, 2020
1 parent 5d4243b commit eb4e173
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/BitX.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ BitX.prototype._request = function (method, resourcePath, data, callback) {
if (res.statusCode !== 200) {
try {
response = JSON.parse(response)
return callback(new Error('luno API error ' + response.error_code + ': ' + response.error))
var err = new Error('luno API error ' + response.error_code + ': ' + response.error)
err.error_code = response.error_code
return callback(err)
} catch (err) {
return callback(new Error('luno unknown API error ' + res.statusCode + ': ' + response))
}
Expand Down

0 comments on commit eb4e173

Please sign in to comment.