Skip to content

Commit

Permalink
Merge pull request #211 from ionut-arm/config-not-found
Browse files Browse the repository at this point in the history
Improve error message when config file is not found
  • Loading branch information
ionut-arm authored Jul 29, 2020
2 parents 14b94d0 + 30e5a9a commit 47296bb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ fn main() -> Result<()> {
let _ = flag::register(SIGTERM, kill_signal.clone())?;
let _ = flag::register(SIGHUP, reload_signal.clone())?;

let mut config_file = ::std::fs::read_to_string(opts.config.clone())?;
let mut config_file = ::std::fs::read_to_string(opts.config.clone()).map_err(|e| {
Error::new(
e.kind(),
format!("Failed to read config file from path: {}", opts.config),
)
})?;
let mut config: ServiceConfig = toml::from_str(&config_file).map_err(|e| {
Error::new(
ErrorKind::InvalidInput,
Expand Down Expand Up @@ -110,7 +115,12 @@ fn main() -> Result<()> {
drop(listener);
drop(threadpool);

config_file = ::std::fs::read_to_string(opts.config.clone())?;
config_file = ::std::fs::read_to_string(opts.config.clone()).map_err(|e| {
Error::new(
e.kind(),
format!("Failed to read config file from path: {}", opts.config),
)
})?;
config = toml::from_str(&config_file).map_err(|e| {
Error::new(
ErrorKind::InvalidInput,
Expand Down

0 comments on commit 47296bb

Please sign in to comment.