Skip to content

Commit 3762240

Browse files
committed
fix: exit on invalid path
1 parent 8d2e382 commit 3762240

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

crates/emmylua_doc_cli/src/main.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,25 @@ fn main() {
1616
let mut files: Vec<String> = Vec::new();
1717
for path in &input {
1818
if path.is_relative() {
19-
let abs_path = current_path.join(path).to_str().unwrap().to_string();
20-
files.push(abs_path);
19+
match current_path.join(path).to_str() {
20+
Some(p) => {
21+
files.push(p.to_string());
22+
}
23+
None => {
24+
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap());
25+
exit(1);
26+
}
27+
}
2128
} else {
22-
files.push(path.to_str().unwrap().to_string());
29+
match path.to_str() {
30+
Some(p) => {
31+
files.push(p.to_string());
32+
}
33+
None => {
34+
eprintln!("Error: {} is not a valid path.", path.to_str().unwrap());
35+
exit(1);
36+
}
37+
}
2338
}
2439
}
2540

0 commit comments

Comments
 (0)