oaapi/audio/
error.rs

1use subtp::ParseError;
2
3use crate::ApiError;
4use crate::ClientError;
5
6/// The error of an audio API calling.
7#[derive(Debug, thiserror::Error)]
8pub enum AudioApiError {
9    /// Client error of an API calling.
10    #[error("Client error: {0:?}")]
11    ClientError(#[from] ClientError),
12    /// API error of an API calling.
13    #[error("API error: {0:?}")]
14    ApiError(#[from] ApiError),
15    /// Failed to format response text of an audio API calling.
16    #[error("Failed to format response text of audio API: {0:?}")]
17    FormatResponseFailed(#[from] TextFormatError),
18    /// Timestamp option mismatch.
19    #[error("Stream option mismatch, this is only available for verbose_json response format.")]
20    TimestampOptionMismatch,
21}
22
23/// The error of formatting a response text.
24#[derive(Debug, thiserror::Error)]
25pub enum TextFormatError {
26    /// The error of formatting a response text into JSON.
27    #[error("Failed to format into JSON: {error:?}, {text}")]
28    FormatJsonFailed {
29        /// The error of deserializing a response text.
30        error: serde_json::Error,
31        /// The raw response text.
32        text: String,
33    },
34    /// The error of formatting a response text into SubRip Subtitle format.
35    #[error("Failed to parse into SubRip Subtitle format: {error:?}, {text}")]
36    ParseSrtFailed {
37        /// The error of parsing a response text.
38        error: ParseError,
39        /// The raw response text.
40        text: String,
41    },
42    /// The error of formatting a response text into WebVTT format.
43    #[error("Failed to parse into WebVTT format: {error:?}, {text}")]
44    ParseVttFailed {
45        /// The error of parsing a response text.
46        error: ParseError,
47        /// The raw response text.
48        text: String,
49    },
50}