Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Commit

Permalink
When a request fails, always set the data property. (#295)
Browse files Browse the repository at this point in the history
This is for consistency between the different ways an Error instance
is created and populated.
  • Loading branch information
blair authored and fb55 committed Apr 5, 2018
1 parent 597a4d0 commit f58b7a2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/clients/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class PublicClient {

if (err) {
err.response = response;
err.data = data;
} else if (response.statusCode > 299) {
err = new Error(
`HTTP ${response.statusCode} Error: ${data && data.message}`
Expand All @@ -72,6 +73,7 @@ class PublicClient {
} else if (data === null) {
err = new Error('Response could not be parsed as JSON');
err.response = response;
err.data = data;
}

if (typeof callback === 'function') {
Expand Down

0 comments on commit f58b7a2

Please sign in to comment.