Skip to content

Update scrapping ant error handling - #100

Merged
orangecoding merged 1 commit into
orangecoding:masterfrom
ivanovvladi:update-scraping-ant-error-handling
Jul 22, 2024
Merged

Update scrapping ant error handling#100
orangecoding merged 1 commit into
orangecoding:masterfrom
ivanovvladi:update-scraping-ant-error-handling

Conversation

@ivanovvladi

Copy link
Copy Markdown
Contributor

Thanks for creating and maintaining this helpful tool

I noticed that scrapping ant sends 423 code with a message

Our browser was detected by target site. Retry the request or try adjusting proxy country, proxy type and browser rendering settings. Our documentation: https://docs.scrapingant.com/ and support email: support@scrapingant.com

and a request doesn't fall into the catch -> retry block. Hence, I'm opening this PR to update the error handling

} 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))) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the status message is not a number, this would generate an exception no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing the PR. That was my first impression, too; however, it returns

    /**
     * A value that is not a number.
     * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function.
     */
    readonly NaN: number;

https://github.com/microsoft/TypeScript/blob/6d3be985c82bead3b41348de76efec8110c677c5/src/lib/es5.d.ts#L585

and the if-else block is evaluated as expected. Since I'm not fully proficient with JS, there might be development standards that defer from the implementation. Let me know if that's the case, and I'd be happy to change it.

@ivanovvladi
ivanovvladi requested a review from orangecoding July 14, 2024 10:28
@orangecoding
orangecoding merged commit e7db4e2 into orangecoding:master Jul 22, 2024
@ivanovvladi
ivanovvladi deleted the update-scraping-ant-error-handling branch August 10, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants