askmike / bitstamp

Bitstamp REST API wrapper
81 stars 54 forks source link

Error handling #36

Closed tuxitor closed 6 years ago

tuxitor commented 7 years ago

When doing a call to a nonexisting endpoint, this one caoncats the error code and buffer. which means I am getting the entire html page in return.

      if (res.statusCode !== 200) {
        return callback(new Error('Bitstamp error ' + res.statusCode + ': ' + buffer));
      }

Is it possible get the return as two different entities, preferably as an object with statusCode and a short descriptive text like this for the most common error codes?

{ statusCode: 404, statusText: 'Not found' }

At least separate the statusCode from the buffer.

tuxitor commented 7 years ago

@askmike A reminder

askmike commented 6 years ago

Sorry that it took so long for a fix :(

askmike commented 6 years ago

You can now access a meta property on the error that (if bitstamp returned valid JSON) contains that object.