Skip to content

Commit

Permalink
Do not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
sorami committed Feb 26, 2024
1 parent dd0aa7c commit 158e282
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ fn run(input_paths: Vec<String>, output_path: String, filetype: String, rules_pa
let requirements = if rules_path.is_empty() {
sink.make_transform_requirements()

Check warning on line 95 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L93-L95

Added lines #L93 - L95 were not covered by tests
} else {
let mapping_rules = {
let file_contents =
std::fs::read_to_string(rules_path).expect("Error reading rules file");
let mapping_rules: MappingRules =
serde_json::from_str(&file_contents).expect("Error parsing rules file");
mapping_rules
};
Requirements {
mapping_rules: Some(mapping_rules),
..sink.make_transform_requirements()
let file_contents = std::fs::read_to_string(&rules_path);
if let Ok(contents) = file_contents {
if let Ok(mapping_rules) = serde_json::from_str::<MappingRules>(&contents) {
Requirements {
mapping_rules: Some(mapping_rules),
..sink.make_transform_requirements()
}

Check warning on line 103 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L97-L103

Added lines #L97 - L103 were not covered by tests
} else {
log::error!("Error parsing rules file");
return;

Check warning on line 106 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L105-L106

Added lines #L105 - L106 were not covered by tests
}
} else {
log::error!("Error reading rules file");
return;

Check warning on line 110 in app/src-tauri/src/main.rs

View check run for this annotation

Codecov / codecov/patch

app/src-tauri/src/main.rs#L109-L110

Added lines #L109 - L110 were not covered by tests
}
};

Expand Down

0 comments on commit 158e282

Please sign in to comment.