taxjar / taxjar-node

Sales Tax API Client for Node
https://developers.taxjar.com/api/reference/?javascript
MIT License
53 stars 24 forks source link

Warning: a promise was rejected with a non-error: [object String] #8

Closed tizol closed 7 years ago

tizol commented 7 years ago

Warning raised when API key is wrong

screen shot 2016-12-01 at 3 53 59 pm ....

API Needs better error handling

Expanded image with full warning 1

Expanded image with full warning 2

Suggestions

https://github.com/danwrong/restler

rest.get('http://google.com').on('complete', function(result) {
  if (result instanceof Error) {
    console.log('Error:', result.message);
    this.retry(5000); // try again after 5 sec
  } else {
    console.log(result);
  }
});

https://github.com/petkaantonov/bluebird/issues/990

if (result.error) {
  const proxiedError = new Error();
  proxiedError.error = result.error.error;
  proxiedError.detail = result.error.detail;
  proxiedError.status = result.error.status;
  reject(proxiedError);
} else {
  resolve(result);
}

https://github.com/danwrong/restler

complete: function(result, response){
  ... 
}