Skip to content

Commit

Permalink
add more error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Deborah Mahn committed Sep 28, 2023
1 parent 6849514 commit e80db0a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/bin/lnk2bodyfile/lnk_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ impl LnkFile {

fn print_bodyfile_for_me(&self) {
let header = self.lnk_file.header();
let linkinfo = self.lnk_file.link_info().clone().unwrap();
let localpath = match LinkInfo::local_base_path(&linkinfo) {
Some(s) => s,
let localpath = match self.lnk_file.link_info() {
Some(s1) => match LinkInfo::local_base_path(s1) {
Some(s2) => s2,
None => "-",
},
None => "-",
};
let arguments = match self.lnk_file.arguments() {
Expand All @@ -46,7 +48,7 @@ impl TryFrom<&Input> for LnkFile {

fn try_from(input: &Input) -> Result<Self, Self::Error> {
let file_path = input.path().to_path_buf();
let file_name = file_path.to_str().unwrap().to_string();
let file_name = file_path.file_name().unwrap().to_str().unwrap().to_string();
match ShellLink::open(file_path) {
Ok(lnk_file) => Ok ( Self { lnk_file, file_name }),
Err(e) => bail!("{:?}: The file {} is not in a valid ShellLink format", e, file_name),
Expand Down

0 comments on commit e80db0a

Please sign in to comment.