http-client: fix returned errors
This commit is contained in:
parent
ca4e938a75
commit
b40ac6e081
@ -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).');
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user