diff options
Diffstat (limited to 'bsie/reader')
-rw-r--r-- | bsie/reader/chain.py | 7 | ||||
-rw-r--r-- | bsie/reader/image/_pillow.py | 2 | ||||
-rw-r--r-- | bsie/reader/image/_raw.py | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/bsie/reader/chain.py b/bsie/reader/chain.py index 8e900e1..db7c2d5 100644 --- a/bsie/reader/chain.py +++ b/bsie/reader/chain.py @@ -73,13 +73,16 @@ class ReaderChain(base.Reader, typing.Generic[T_CONTENT]): return hash((super().__hash__(), self._children)) def __call__(self, path: str) -> T_CONTENT: + raise_error = errors.UnsupportedFileFormatError for child in self._children: try: return child(path) + except errors.UnsupportedFileFormatError: + pass except errors.ReaderError: # child cannot read the file, skip. - pass + raise_error = errors.ReaderError # type: ignore [assignment] # mypy is confused - raise errors.ReaderError(path) + raise raise_error(path) ## EOF ## diff --git a/bsie/reader/image/_pillow.py b/bsie/reader/image/_pillow.py index ee0662d..3144509 100644 --- a/bsie/reader/image/_pillow.py +++ b/bsie/reader/image/_pillow.py @@ -31,6 +31,8 @@ class PillowImage(base.Reader): try: # open file with PIL return PIL.Image.open(path) + except PIL.UnidentifiedImageError as err: + raise errors.UnsupportedFileFormatError(path) from err except IOError as err: raise errors.ReaderError(path) from err diff --git a/bsie/reader/image/_raw.py b/bsie/reader/image/_raw.py index 77be357..cd60453 100644 --- a/bsie/reader/image/_raw.py +++ b/bsie/reader/image/_raw.py @@ -45,7 +45,7 @@ class RawImage(base.Reader): def __call__(self, path: str) -> PIL.Image: # perform quick checks first if not self._match(path): - raise errors.ReaderError(path) + raise errors.UnsupportedFileFormatError(path) try: # open file with rawpy |