Skip to content

Commit

Permalink
Add a better error message when get_file_name fails
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Dec 15, 2023
1 parent d94930d commit a17e66e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions forc/src/cli/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ pub struct Command {
}

fn get_file_name(path: &Path) -> String {
path.file_name()
.expect("Failed to read file name")
.to_str()
.expect("Failed to print file name")
.to_string()
if let Some(path_str) = path.file_name() {
if let Some(path_str) = path_str.to_str() {
return path_str.to_owned();
}
}
panic!("Failed to read file name from {path:?}");
}

pub(crate) fn exec(command: PluginsCommand) -> ForcResult<()> {
Expand Down

0 comments on commit a17e66e

Please sign in to comment.