Skip to main content

narrate_this/
error.rs

1use thiserror::Error;
2
3/// Errors returned by the SDK.
4///
5/// Each variant corresponds to a pipeline stage or infrastructure concern.
6/// Non-fatal errors (e.g. a media search miss) are logged as warnings via
7/// `tracing` and won't stop the pipeline — only fatal errors surface here.
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum SdkError {
11    #[error("TTS error: {0}")]
12    Tts(String),
13
14    #[error("LLM error: {0}")]
15    Llm(String),
16
17    #[error("Media search error: {0}")]
18    MediaSearch(String),
19
20    #[error("Media planner error: {0}")]
21    MediaPlanner(String),
22
23    #[error("Web scraper error: {0}")]
24    WebScraper(String),
25
26    #[error("Audio storage error: {0}")]
27    AudioStorage(String),
28
29    #[error("Cache error: {0}")]
30    Cache(String),
31
32    #[error("Video render error: {0}")]
33    VideoRender(String),
34
35    #[error("Configuration error: {0}")]
36    Config(String),
37
38    #[error("HTTP error: {0}")]
39    Http(#[from] reqwest::Error),
40
41    #[error("IO error: {0}")]
42    Io(#[from] std::io::Error),
43
44    #[error("JSON error: {0}")]
45    Json(#[from] serde_json::Error),
46}
47
48/// Convenience alias for `std::result::Result<T, SdkError>`.
49pub type Result<T> = std::result::Result<T, SdkError>;