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
Conversation
e205ae1
to
af4faf3
Compare
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
d7fd993
to
251b33e
Compare
src/proxy/config.rs
Outdated
@@ -151,17 +150,15 @@ impl Config { | |||
} | |||
} | |||
|
|||
#[cfg(test)] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)?) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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>
251b33e
to
3cf7aff
Compare
Design error type.
Fixes: #23