mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-31 14:34:40 +00:00
fix: set valid=false for invalid backends
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
parent
b8d2286dd1
commit
dc473efed0
@ -143,11 +143,13 @@ class InputDocument(BaseModel):
|
|||||||
self.valid = False
|
self.valid = False
|
||||||
|
|
||||||
except (FileNotFoundError, OSError) as e:
|
except (FileNotFoundError, OSError) as e:
|
||||||
|
self.valid = False
|
||||||
_log.exception(
|
_log.exception(
|
||||||
f"File {self.file.name} not found or cannot be opened.", exc_info=e
|
f"File {self.file.name} not found or cannot be opened.", exc_info=e
|
||||||
)
|
)
|
||||||
# raise
|
# raise
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
|
self.valid = False
|
||||||
_log.exception(
|
_log.exception(
|
||||||
f"An unexpected error occurred while opening the document {self.file.name}",
|
f"An unexpected error occurred while opening the document {self.file.name}",
|
||||||
exc_info=e,
|
exc_info=e,
|
||||||
@ -166,6 +168,8 @@ class InputDocument(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._backend = backend(self, path_or_stream=path_or_stream)
|
self._backend = backend(self, path_or_stream=path_or_stream)
|
||||||
|
if not self._backend.is_valid():
|
||||||
|
self.valid = False
|
||||||
|
|
||||||
|
|
||||||
class DocumentFormat(str, Enum):
|
class DocumentFormat(str, Enum):
|
||||||
|
Loading…
Reference in New Issue
Block a user