Skip to content

Commit

Permalink
feat: Log error if config parsing failed
Browse files Browse the repository at this point in the history
  • Loading branch information
techsy730 authored Mar 10, 2022
1 parent b22b6ea commit d508ff1
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ impl Config {
match ron::from_str(config) {
Ok(config) => return config,
Err(why) => {
tracing::error!("{}: {:?}", path, why);
tracing::error!(
"{:?}: {} on line {}, column {}",
path,
why.code,
why.position.line,
why.position.col
);
}
}
}
Expand All @@ -58,13 +64,23 @@ impl Config {
if let Ok(dir) = directory.read_dir() {
for entry in dir.filter_map(Result::ok) {
if let Ok(string) = fs::read_to_string(entry.path()) {
if let Ok(buffer) = ron::from_str::<BTreeMap<i8, HashSet<String>>>(&string)
{
for (priority, commands) in buffer {
for command in commands {
assignments.insert(command, priority);
}
}
match ron::from_str::<BTreeMap<i8, HashSet<String>>>(&string) {
Ok(buffer) => {
for (priority, commands) in buffer {
for command in commands {
assignments.insert(command, priority);
}
}
},
Err(why) => {
tracing::error!(
"{:?}: {} on line {}, column {}",
entry.path(),
why.code,
why.position.line,
why.position.col
);
}
}
}
}
Expand Down

0 comments on commit d508ff1

Please # to comment.