Skip to content

Commit

Permalink
Handle error when creating reader objects
Browse files Browse the repository at this point in the history
  • Loading branch information
CedricHermansBIT committed Feb 28, 2024
1 parent a850345 commit 7c06732
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,16 @@ impl ReadsReader {
fn from_path(path: String, n: u16) -> ReadsReader {
if path.ends_with(".bam") {
let reader = BamReader::from_path(path, n);
ReadsReader::BamReader(reader.unwrap())
match reader {
Ok(reader) => ReadsReader::BamReader(reader),
Err(e) => panic!("{}", e),
}
} else if path.ends_with(".sam") {
let reader = SamReader::from_path(path);
ReadsReader::SamReader(reader.unwrap())
match reader {
Ok(reader) => ReadsReader::SamReader(reader),
Err(e) => panic!("{}", e),
}
} else {
panic!("File type not supported");
}
Expand Down

0 comments on commit 7c06732

Please sign in to comment.