From a3cfd3f4f089b7ef0cb33faf5fe7439120948811 Mon Sep 17 00:00:00 2001
From: Martin Larralde <martin.larralde@embl.de>
Date: Fri, 30 Aug 2024 22:23:40 +0200
Subject: [PATCH] Fix TRANSFAC parser unwrapping potential error in
 `lightmotif-io`

---
 lightmotif-io/src/transfac/reader.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lightmotif-io/src/transfac/reader.rs b/lightmotif-io/src/transfac/reader.rs
index 6a8dcbf..ef07ff9 100644
--- a/lightmotif-io/src/transfac/reader.rs
+++ b/lightmotif-io/src/transfac/reader.rs
@@ -84,7 +84,10 @@ impl<B: BufRead, A: Alphabet> Iterator for Reader<B, A> {
         }
 
         if !self.buffer.is_empty() {
-            let record = super::parse::parse_record::<A>(&self.buffer).unwrap().1;
+            let record = match super::parse::parse_record::<A>(&self.buffer) {
+                Err(e) => return Some(Err(Error::from(e))),
+                Ok(x) => x.1,
+            };
             self.buffer.clear();
             self.last = 0;
             Some(Ok(record))
-- 
GitLab