diff --git a/forc/src/cli/commands/plugins.rs b/forc/src/cli/commands/plugins.rs index bfa3209c51e..794b79a74ca 100644 --- a/forc/src/cli/commands/plugins.rs +++ b/forc/src/cli/commands/plugins.rs @@ -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<()> {