From 7c06732d07137d9297edf80e5cc766b10cebaf80 Mon Sep 17 00:00:00 2001 From: CedricHermansBIT Date: Wed, 28 Feb 2024 10:18:35 +0100 Subject: [PATCH] Handle error when creating reader objects --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5ab7152..b57329d 100755 --- a/src/main.rs +++ b/src/main.rs @@ -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"); }