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 error types to use thiserror and internalize BuildError #228

Merged
merged 3 commits into from
Dec 12, 2023

Conversation

Xtansia
Copy link
Collaborator

@Xtansia Xtansia commented Dec 11, 2023

Description

Refactors the error types to use thiserror and internalize the BuildError type.

Split from #132.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (71b677f) 74.00% compared to head (f24b729) 74.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #228      +/-   ##
==========================================
+ Coverage   74.00%   74.07%   +0.06%     
==========================================
  Files         403      403              
  Lines       64198    64138      -60     
==========================================
  Hits        47508    47508              
+ Misses      16690    16630      -60     
Flag Coverage Δ
integration 74.07% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@Xtansia Xtansia force-pushed the refactor/error branch 2 times, most recently from 6f305b2 to f52b6bc Compare December 11, 2023 03:32
certs.push(reqwest::Certificate::from_pem(cert.join("\n").as_bytes())?);
certs.push(
reqwest::Certificate::from_pem(cert.join("\n").as_bytes())
.map_err(CertificateError::MalformedCertificate)?,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super nit:

Suggested change
.map_err(CertificateError::MalformedCertificate)?,
.map_err(CertificateError::MalformedCertificate)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is imposed by cargo fmt due to how it decides to break the line. Only way around it is to restructure the line entirely.

}
}
#[error("reqwest error: {0}")]
Reqwest(#[from] reqwest::Error),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest to keep Http here, Reqwest is just client implementation, I don't think we should expose it

Suggested change
Reqwest(#[from] reqwest::Error),
Http(#[from] reqwest::Error),

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see, we use it at build time, may be ClientBuilder would be better one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already expose reqwest types externally so that's not a new problem as such. But these variants aren't actually exposed other than via the descriptor text or debug formatting. But certainly happy to rename to something that makes more sense to specific cases

@Xtansia Xtansia merged commit 360e88c into opensearch-project:main Dec 12, 2023
32 checks passed
@Xtansia Xtansia deleted the refactor/error branch December 12, 2023 19:40
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