Skip to content

Commit

Permalink
http-client: fix returned errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Oct 5, 2017
1 parent ca4e938 commit b40ac6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ HTTPClient.prototype._request = async function _request(method, endpoint, json)
if (res.statusCode === 401)
throw new Error('Unauthorized (bad API key).');

if (res.statusCode !== 200)
throw new Error(`Status code: ${res.statusCode}.`);

if (res.type !== 'json')
throw new Error('Bad response (wrong content-type).');

Expand All @@ -242,6 +239,9 @@ HTTPClient.prototype._request = async function _request(method, endpoint, json)
if (res.body.error)
throw new Error(res.body.error.message);

if (res.statusCode !== 200)
throw new Error(`Status code: ${res.statusCode}.`);

return res.body;
};

Expand Down

0 comments on commit b40ac6e

Please sign in to comment.