Skip to content

Commit

Permalink
update error handling (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanovvladi authored Jul 22, 2024
1 parent 06c4ebb commit e7db4e2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/services/requestDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ function makeDriver(headers = {}) {
},
});
const result = await response.text();
if (EXPECTED_STATUS_CODES.includes(response.status)) {
throw new Error(`${response.status}`);
}
if (cookies.length === 0) {
cookies = response.headers.raw()['set-cookie'] || [];
}
callback(null, result);
} catch (exception) {
/* eslint-disable no-console */
if (!EXPECTED_STATUS_CODES.includes(exception.response?.status)) {
if (!EXPECTED_STATUS_CODES.includes(exception.response?.status) && !EXPECTED_STATUS_CODES.includes(Number(exception.message))) {
console.error(`Error while trying to scrape data from scraping ant. Received error: ${exception.message}`);
callback(null, []);
return;
Expand Down

0 comments on commit e7db4e2

Please sign in to comment.