taxjar / taxjar-node

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

Add error message to proxied error #34

Closed ScottRudiger closed 5 years ago

ScottRudiger commented 5 years ago

To aid in debugging and error handling, errors will now include a message in the format `TaxJar: ${error} - ${detail}`.

For example, assuming a 401 - Unauthorized error:

client.categories().catch(err => {
  console.assert(err.message === "TaxJar: Unauthorized - Not authorized for route 'GET /v2/categories'");
  console.assert(err.error === 'Unauthorized');
  console.assert(err.detail === "Not authorized for route 'GET /v2/categories'");
  console.assert(err.status === 401);
});

See #33 for further discussion.