Allen Porter 6edf06f8a4
Converge stream av open methods, options, and error handling (#134020)
* Converge stream av open methods, options, and error handling

* Remove exception that is never thrown

* Update exceptions thrown in generic tests

* Increase stream test coverage
2024-12-27 18:47:33 -08:00

33 lines
977 B
Python

"""Stream component exceptions."""
from homeassistant.exceptions import HomeAssistantError
from .const import StreamClientError
class StreamOpenClientError(HomeAssistantError):
"""Raised when client error received when trying to open a stream.
:param stream_client_error: The type of client error
"""
def __init__(self, message: str, error_code: StreamClientError) -> None:
"""Initialize a stream open client error."""
super().__init__(message)
self.error_code = error_code
class StreamWorkerError(Exception):
"""An exception thrown while processing a stream."""
def __init__(
self, message: str, error_code: StreamClientError = StreamClientError.Other
) -> None:
"""Initialize a stream worker error."""
super().__init__(message)
self.error_code = error_code
class StreamEndedError(StreamWorkerError):
"""Raised when the stream is complete, exposed for facilitating testing."""