Skip to main content

kothok_edge_tts/
error.rs

1//! Crate-level error type for Edge-TTS synthesis failures.
2
3use thiserror::Error;
4
5/// All ways a synthesis request can fail.
6///
7/// Callers typically propagate this with `?` or match on a variant to
8/// decide whether to retry (e.g. [`TtsError::Connect`] after a network blip).
9#[derive(Debug, Error)]
10pub enum TtsError {
11    /// The WebSocket handshake or DRM-token auth failed after all retry
12    /// attempts. The inner string is the last underlying error message.
13    #[error("ws connect failed after retries: {0}")]
14    Connect(String),
15
16    /// Transport-level WebSocket error (handshake, frame decode, TLS).
17    #[error("ws: {0}")]
18    Ws(#[from] tokio_tungstenite::tungstenite::Error),
19
20    /// I/O error on the underlying TCP stream, including receive idle timeout.
21    #[error("io: {0}")]
22    Io(#[from] std::io::Error),
23
24    /// The turn completed (or the stream closed) without any audio frames.
25    #[error("no audio received")]
26    NoAudio,
27}