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 0d51e7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions forc/src/cli/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ 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(Some(path_str)) = path.file_name().map(|path_str| path_str.to_str()) {
path_str.to_owned()
} else {
panic!("Failed to read file name from {path:?}")
}
}

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

0 comments on commit 0d51e7a

Please sign in to comment.