Skip to main content

edge_tts_rust/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("invalid rate value: {0}")]
6    InvalidRate(String),
7    #[error("invalid volume value: {0}")]
8    InvalidVolume(String),
9    #[error("invalid pitch value: {0}")]
10    InvalidPitch(String),
11    #[error("invalid voice value: {0}")]
12    InvalidVoice(String),
13    #[error("text chunk size must be greater than zero")]
14    InvalidChunkSize,
15    #[error("failed to split text safely")]
16    InvalidSplitPoint,
17    #[error("websocket response was missing expected headers")]
18    MissingHeaders,
19    #[error("unexpected websocket response: {0}")]
20    UnexpectedResponse(&'static str),
21    #[error("unknown websocket path: {0}")]
22    UnknownPath(String),
23    #[error("unknown metadata type: {0}")]
24    UnknownMetadata(String),
25    #[error("no audio was received from the service")]
26    NoAudioReceived,
27    #[error("http error: {0}")]
28    Http(#[from] reqwest::Error),
29    #[error("websocket error: {0}")]
30    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
31    #[error("json error: {0}")]
32    Json(#[from] serde_json::Error),
33    #[error("io error: {0}")]
34    Io(#[from] std::io::Error),
35    #[error("http request build error: {0}")]
36    HttpRequest(#[from] http::Error),
37}
38
39pub type Result<T> = std::result::Result<T, Error>;