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: design error type #24

Merged
merged 1 commit into from Jul 7, 2023
Merged

Conversation

yaoyinnan
Copy link
Collaborator

Design error type.

Fixes: #23

@codecov
Copy link

codecov bot commented Jul 5, 2023

Codecov Report

Merging #24 (251b33e) into main (fdb73b9) will increase coverage by 1.32%.
The diff coverage is 54.16%.

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   18.75%   20.07%   +1.32%     
==========================================
  Files           7       11       +4     
  Lines         272      274       +2     
==========================================
+ Hits           51       55       +4     
+ Misses        221      219       -2     
Flag Coverage Δ
pika-proxy 20.07% <54.16%> (+1.32%) ⬆️

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

Impacted Files Coverage Δ
src/error/config.rs 0.00% <0.00%> (ø)
src/error/mod.rs 0.00% <0.00%> (ø)
src/error/network.rs 0.00% <0.00%> (ø)
src/error/redis.rs 0.00% <ø> (ø)
src/error/server.rs 0.00% <0.00%> (ø)
src/proxy/proxy.rs 0.00% <0.00%> (ø)
src/main.rs 4.76% <50.00%> (ø)
src/proxy/config.rs 85.71% <100.00%> (+8.79%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

src/error/error.rs Outdated Show resolved Hide resolved
@yaoyinnan yaoyinnan force-pushed the 23/refactor/error branch 4 times, most recently from d7fd993 to 251b33e Compare July 6, 2023 03:58
Aya0wind
Aya0wind previously approved these changes Jul 6, 2023
@@ -151,17 +150,15 @@ impl Config {
}
}

#[cfg(test)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this line? It saves compile time and fix clippy warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I deleted it by mistake

Ok(config)
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self> {
let content = std::fs::read_to_string(path)?;
Ok(toml::from_str(&content).map_err(ConfigError::ParseToml)?)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about this, I think most crates split the errors and result into different folders, but if try chain got stable, this design would be more clear, check rust-lang/rust#84277.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it will be clearer this way. I refer to the design of error handling in some projects, and after discussing with @Aya0wind, I use this type of error handling transformation scheme. Split by error type, not mod. It can be expanded on this basis later, currently these error types are only set according to initial expectations.

@Dennis-Zhang-SH
Copy link
Contributor

At lease it's much more clear than before, I can go with the map err thing.

Design error type.

Fixes: pikiwidb#23

Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
@yaoyinnan yaoyinnan merged commit 8db7a67 into pikiwidb:main Jul 7, 2023
6 checks passed
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.

design error type
3 participants