-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexceptions.py
More file actions
36 lines (28 loc) · 1.38 KB
/
exceptions.py
File metadata and controls
36 lines (28 loc) · 1.38 KB
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
33
34
35
36
"""Exceptions emitted by the pipeline."""
from collections.abc import Iterator
from dve.core_engine.backends.implementations.spark.types import SparkEntities
from dve.core_engine.message import FeedbackMessage
from dve.core_engine.type_hints import Messages
class CriticalProcessingError(ValueError):
"""An exception emitted if critical errors are received."""
def __init__(
self, error_message: str, *args: object, messages: Messages, entities: SparkEntities
) -> None:
super().__init__(error_message, *args)
self.error_message = error_message
"""The error message explaining the critical processing error."""
self.messages = messages
"""The messages gathered at the time the error was emitted."""
self.entities = entities
"""The entities as they exist at the time the error was emitted."""
@property
def critical_messages(self) -> Iterator[FeedbackMessage]:
"""Critical messages which caused the processing error."""
yield from filter(lambda message: message.is_critical, self.messages)
@classmethod
def from_exception(cls, exc:Exception):
return cls(error_message = repr(exc),
entities=None,
messages=[])
class EntityTypeMismatch(TypeError):
"""An exception emitted if entity type outputs from two collaborative objects are different."""