-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathexceptions.py
More file actions
32 lines (23 loc) · 1007 Bytes
/
exceptions.py
File metadata and controls
32 lines (23 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from ragbits.document_search.documents.element import Element
class EnricherError(Exception):
"""
Class for all exceptions raised by the element enricher and router.
"""
def __init__(self, message: str) -> None:
super().__init__(message)
self.message = message
class EnricherNotFoundError(EnricherError):
"""
Raised when no enricher was found for the element type.
"""
def __init__(self, element_type: type[Element]) -> None:
super().__init__(f"No enricher found for the element type {element_type}")
self.element_type = element_type
class EnricherElementNotSupportedError(EnricherError):
"""
Raised when the element type is not supported by the enricher.
"""
def __init__(self, enricher_name: str, element_type: type[Element]) -> None:
super().__init__(f"Element type {element_type} is not supported by the {enricher_name}")
self.enricher_name = enricher_name
self.element_type = element_type