Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dart): correctly rethrow 4xx errors #1859

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Conversation

aallam
Copy link
Member

@aallam aallam commented Aug 1, 2023

🧭 What and Why

The current error-throwing logic doesn't stop the retry operations, which it should.

Changes included:

Correctly detect 4xx errors to immediately stop retrying calls.

@aallam aallam requested a review from a team as a code owner August 1, 2023 13:41
@netlify
Copy link

netlify bot commented Aug 1, 2023

Deploy Preview for api-clients-automation ready!

Name Link
🔨 Latest commit b39a2dd
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/64c90d8748f01f000797ad25
😎 Deploy Preview https://deploy-preview-1859--api-clients-automation.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@algolia-bot
Copy link
Collaborator

algolia-bot commented Aug 1, 2023

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

millotp
millotp previously approved these changes Aug 1, 2023
Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

can't melos bump the version ? I think it works for non generated file too no ?

@@ -61,7 +61,7 @@ final class RetryStrategy {
host.failed();
errors.add(e);
} on AlgoliaApiException catch (e) {
if (e.statusCode / 100 == 4) rethrow;
if (e.statusCode ~/ 100 == 4) rethrow;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what in hell is this operator ahah

Copy link
Member

Choose a reason for hiding this comment

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

is that a divide but approximative that rounds? XD

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, it's JS effect 😅
In dart, when you divide an int by and int, (e.g. 403 / 100) guess what you get ? the answer: 4.03 🤦‍♂️
The operator ~/ is to get an int result 🥲

Copy link
Member

Choose a reason for hiding this comment

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

🤯 oh oki, I'd go with e.StatusCode >= 400 && e.StatusCode < 500 in general but if it works like this then it's nice

Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

noice

@aallam aallam merged commit 4ebd50a into main Aug 1, 2023
16 checks passed
@aallam aallam deleted the fix/dart-rethrow-4xx branch August 1, 2023 14:05
algolia-bot added a commit to algolia/algoliasearch-client-dart that referenced this pull request Aug 1, 2023
algolia/api-clients-automation#1859

Co-authored-by: Mouaad Aallam <mouaad.aallam@algolia.com>
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.

None yet

4 participants