mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
87 lines
2.3 KiB
Python
87 lines
2.3 KiB
Python
"""Assist pipeline errors."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from homeassistant.exceptions import HomeAssistantError
|
|
|
|
if TYPE_CHECKING:
|
|
from .pipeline import PipelineStage
|
|
|
|
|
|
class PipelineError(HomeAssistantError):
|
|
"""Base class for pipeline errors."""
|
|
|
|
def __init__(self, code: str, message: str) -> None:
|
|
"""Set error message."""
|
|
self.code = code
|
|
self.message = message
|
|
|
|
super().__init__(f"Pipeline error code={code}, message={message}")
|
|
|
|
|
|
class PipelineNotFound(PipelineError):
|
|
"""Unspecified pipeline picked."""
|
|
|
|
|
|
class WakeWordDetectionError(PipelineError):
|
|
"""Error in wake-word-detection portion of pipeline."""
|
|
|
|
|
|
class WakeWordDetectionAborted(WakeWordDetectionError):
|
|
"""Wake-word-detection was aborted."""
|
|
|
|
def __init__(self) -> None:
|
|
"""Set error message."""
|
|
super().__init__("wake_word_detection_aborted", "")
|
|
|
|
|
|
class WakeWordTimeoutError(WakeWordDetectionError):
|
|
"""Timeout when wake word was not detected."""
|
|
|
|
|
|
class SpeechToTextError(PipelineError):
|
|
"""Error in speech-to-text portion of pipeline."""
|
|
|
|
|
|
class DuplicateWakeUpDetectedError(WakeWordDetectionError):
|
|
"""Error when multiple voice assistants wake up at the same time (same wake word)."""
|
|
|
|
def __init__(self, wake_up_phrase: str) -> None:
|
|
"""Set error message."""
|
|
super().__init__(
|
|
"duplicate_wake_up_detected",
|
|
f"Duplicate wake-up detected for {wake_up_phrase}",
|
|
)
|
|
|
|
|
|
class IntentRecognitionError(PipelineError):
|
|
"""Error in intent recognition portion of pipeline."""
|
|
|
|
|
|
class TextToSpeechError(PipelineError):
|
|
"""Error in text-to-speech portion of pipeline."""
|
|
|
|
|
|
class PipelineRunValidationError(PipelineError):
|
|
"""Error when a pipeline run is not valid."""
|
|
|
|
def __init__(self, message: str) -> None:
|
|
"""Set error message."""
|
|
super().__init__("validation-error", message)
|
|
|
|
|
|
class InvalidPipelineStagesError(PipelineRunValidationError):
|
|
"""Error when given an invalid combination of start/end stages."""
|
|
|
|
def __init__(
|
|
self,
|
|
start_stage: PipelineStage,
|
|
end_stage: PipelineStage,
|
|
) -> None:
|
|
"""Set error message."""
|
|
super().__init__(
|
|
f"Invalid stage combination: start={start_stage}, end={end_stage}"
|
|
)
|