From afd165000c1661a9cca117a4844ad3f89d926fdb Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 16 Jan 2023 20:53:39 +0100 Subject: unsupported file format exception --- bsie/reader/image/_pillow.py | 2 ++ bsie/reader/image/_raw.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'bsie/reader/image') 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 -- cgit v1.2.3