Skip to content

Commit

Permalink
Add exception for invalid encodings (#88)
Browse files Browse the repository at this point in the history
Co-authored-by: Mathias Kuhring <mathias.kuhring@bih-charite.de>
Co-authored-by: Thomas Sell <thomas.sell@bih-charite.de>
  • Loading branch information
3 people authored Jan 15, 2024
1 parent 8a9ecbd commit 2892ffb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions altamisa/isatab/parse_assay_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@ def _read_next_line(self):
self.unique_rows.add("\t".join(self._line))
except StopIteration:
self._line = None
except UnicodeDecodeError as e: # pragma: no cover
msg = f"Invalid encoding of study file '{self._filename}' (use Unicode/UTF-8)."
raise ParseIsatabException(msg) from e
return prev_line

def read(self):
Expand Down Expand Up @@ -970,6 +973,9 @@ def _read_next_line(self):
self.unique_rows.add("\t".join(self._line))
except StopIteration:
self._line = None
except UnicodeDecodeError as e: # pragma: no cover
msg = f"Invalid encoding of assay file '{self._filename}' (use Unicode/UTF-8)."
raise ParseIsatabException(msg) from e
return prev_line

def read(self):
Expand Down
3 changes: 3 additions & 0 deletions altamisa/isatab/parse_investigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def _read_next_line(self) -> Optional[List[str]]:
self._line = list_strip(next(self._reader))
except StopIteration:
self._line = None
except UnicodeDecodeError as e: # pragma: no cover
msg = f"Invalid encoding of investigation file '{self._filename}' (use Unicode/UTF-8)."
raise ParseIsatabException(msg) from e
return prev_line

def _next_line_startswith_comment(self):
Expand Down

0 comments on commit 2892ffb

Please sign in to comment.