Skip to main content

raqeem_core/
error.rs

1use std::path::PathBuf;
2
3/// Everything that can go wrong on the way from an audio file to a transcript.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    #[error("could not read audio file {path}: {source}")]
7    ReadFile {
8        path: PathBuf,
9        source: std::io::Error,
10    },
11
12    #[error("request to {url} failed: {source}")]
13    Http { url: String, source: reqwest::Error },
14
15    #[error("endpoint returned HTTP {status}: {body}")]
16    Api { status: u16, body: String },
17
18    #[error("could not parse endpoint response (expected a JSON object with a string \"text\" field), got: {body}")]
19    BadResponse { body: String },
20}
21
22pub type Result<T> = std::result::Result<T, Error>;