use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum CaptureError {
#[error("target window not found: {0}")]
TargetNotFound(String),
#[error("target window closed")]
WindowClosed,
#[error("capture backend error: {0}")]
Backend(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("image decode error: {0}")]
Decode(String),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum SinkError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("serialization error: {0}")]
Serde(#[from] serde_json::Error),
#[error("image encode error: {0}")]
Encode(String),
#[error("channel receiver disconnected")]
Disconnected,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum TranscribeError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("serialization error: {0}")]
Serde(#[from] serde_json::Error),
#[error("transcribe command exited with code {0}: {1}")]
CommandFailed(i32, String),
#[error("could not parse transcriber output: {0}")]
Parse(String),
#[error("audio error: {0}")]
Audio(String),
#[error("managed transcriber setup failed: {0}")]
Setup(String),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum RecordError {
#[error("ffmpeg not found on PATH — install ffmpeg and ensure it is on PATH")]
FfmpegNotFound,
#[error("ffmpeg exited with status {0}")]
FfmpegFailed(std::process::ExitStatus),
#[error("no microphone / audio input device available")]
NoInputDevice,
#[error("unsupported audio input sample format")]
UnsupportedSampleFormat,
#[error("audio device error: {0}")]
Audio(String),
#[error("wav write error: {0}")]
Wav(String),
#[error(transparent)]
Capture(#[from] CaptureError),
#[error("recording requires a Windows build with the `record` feature")]
Unsupported,
#[error(transparent)]
Io(#[from] std::io::Error),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Capture(#[from] CaptureError),
#[error(transparent)]
Sink(#[from] SinkError),
#[error(transparent)]
Record(#[from] RecordError),
#[error(transparent)]
Transcribe(#[from] TranscribeError),
#[error("invalid configuration: {0}")]
Config(String),
#[error("no capture backend available: {0}")]
NoBackend(String),
#[error(transparent)]
Io(#[from] std::io::Error),
}