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

refactor(lib): consolidate reqwest errors #125

Merged
merged 3 commits into from
Dec 1, 2024
Merged

Conversation

Rolv-Apneseth
Copy link
Collaborator

This removes Error::RequestEncode and Error::RequestDecode. Also did some minor refactoring to remove excessive indentation, and implemented the test for Error::Reqwest (though I think maybe that's not necessary - feels like testing implementation details).

Note: I believe I accidentally made this branch from the main repo and not my fork - my bad. If that's an issue I can make a new PR.

Copy link

codspeed-hq bot commented Nov 16, 2024

CodSpeed Performance Report

Merging #125 will not alter performance

Comparing consolidate-reqwest-errors (5514c75) with v3 (ccb494a)

Summary

✅ 6 untouched benchmarks

Comment on lines -558 to +535
Err(e) => Err(Error::RequestEncode(e)),
Err(_) => Err(Error::InvalidRequest(resp.text().await?)),
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should add a test for this.

E.g., sending a request that is too long. I don't know that is the limit of local servers, but the public API has a limit of 1500 characters, I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I'll have a look

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is that last commit there what you had in mind?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, it looks good @Rolv-Apneseth! Sorry, I didn't see the notification...

Could you fix the conflicts so I can run tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm away at the moment but I can have a look when I'm back, hopefully on the weekend

Copy link
Owner

Choose a reason for hiding this comment

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

No issue, ping me when you're back ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jeertmans Did a rebase, hopefully it's all good now

Copy link
Owner

Choose a reason for hiding this comment

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

Perfect, thanks! We will fix CodSpell's warnings later (we need to ignore them)

Copy link

codecov bot commented Nov 16, 2024

Codecov Report

Attention: Patch coverage is 28.94737% with 27 lines in your changes missing coverage. Please review.

Project coverage is 19.47%. Comparing base (ccb494a) to head (5514c75).
Report is 1 commits behind head on v3.

Files with missing lines Patch % Lines
src/api/server.rs 28.94% 27 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v3     #125      +/-   ##
==========================================
+ Coverage   19.06%   19.47%   +0.40%     
==========================================
  Files          14       14              
  Lines         577      570       -7     
==========================================
+ Hits          110      111       +1     
+ Misses        467      459       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Rolv-Apneseth Rolv-Apneseth force-pushed the consolidate-reqwest-errors branch from a81a453 to 5514c75 Compare December 1, 2024 00:16
let req = Request::default().with_text("je suis une poupee");
assert!(client.check(&req).await.inspect_err(dbg_err).is_ok());

// Too long
let req = Request::default().with_text("Repeat ".repeat(1500));
Copy link

Choose a reason for hiding this comment

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

[LanguageTool] reported by reviewdog 🐶
Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses
Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
Category: PUNCTUATION

// Too long
let req = Request::default()
.with_data_str(&format!(
"{{\"annotation\":[{{\"text\": \"{}\"}}]}}",
Copy link

Choose a reason for hiding this comment

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

[LanguageTool] reported by reviewdog 🐶
Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses
Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
Category: PUNCTUATION

@jeertmans jeertmans merged commit 1665a9d into v3 Dec 1, 2024
12 of 13 checks passed
@jeertmans jeertmans deleted the consolidate-reqwest-errors branch December 1, 2024 10:26
@jeertmans jeertmans changed the title refactor: consolidate reqwest errors refactor(lib): consolidate reqwest errors Dec 1, 2024
@jeertmans jeertmans added the library Relate to the library (i.e., crate) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library Relate to the library (i.e., crate)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants