Skip to content

Commit

Permalink
replace panic to std::io::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad committed May 1, 2023
1 parent ed8fc7b commit e0ca0e8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
15 changes: 10 additions & 5 deletions src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ pub(crate) fn open_doc_read_data<P: AsRef<Path>>(
}
}
Ok(Event::Eof) => break,
Err(e) => panic!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
Err(e) => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
))
}
_ => (),
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/docx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,16 @@ impl MsDoc<Docx> for Docx {
}
}
Ok(Event::Eof) => break, // exits the loop when reaching end of file
Err(e) => panic!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
Err(e) => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
))
}
_ => (),
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/odp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ impl OpenOfficeDoc<Odp> for Odp {
// }
// },
// Ok(Event::Eof) => break,
// Err(e) => panic!("Error at position {}: {:?}", xml_reader.buffer_position(), e),
// Err(e) => {
// return Err(io::Error::new(
// io::ErrorKind::Other,
// format!(
// "Error at position {}: {:?}",
// xml_reader.buffer_position(),
// e
// ),
// ))
// }
// _ => (),
// }
// }
Expand Down
15 changes: 10 additions & 5 deletions src/pptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ impl MsDoc<Pptx> for Pptx {
}
}
Ok(Event::Eof) => break, // exits the loop when reaching end of file
Err(e) => panic!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
Err(e) => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
))
}
_ => (),
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/xlsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ impl MsDoc<Xlsx> for Xlsx {
}
}
Ok(Event::Eof) => break, // exits the loop when reaching end of file
Err(e) => panic!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
Err(e) => {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"Error at position {}: {:?}",
xml_reader.buffer_position(),
e
),
))
}
_ => (),
}
}
Expand Down

0 comments on commit e0ca0e8

Please sign in to comment.