openai_interface/
errors.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum OapiError {
5    #[error("Failed to send request: {0}")]
6    SendError(String),
7    #[error("Response error: {0}")]
8    ResponseError(String),
9    #[error("Invalid response code: {0}")]
10    ResponseCode(u16),
11    #[error("Invalid response status: {0}")]
12    ResponseStatus(u16),
13    #[error("Failed to parse to String: {0}")]
14    SseParseError(String),
15    #[error("{0}")]
16    StreamError(String),
17    /// If the request is a streaming request, but the context is not streaming.
18    #[error("You cannot post a streaming request in a non-streaming context")]
19    NonStreamingViolation,
20    /// If the request is a non-streaming request, but the context is streaming.
21    #[error("You cannot post a non-streaming request in a streaming context")]
22    StreamingViolation,
23    #[error("Deserialization error:\n{0}\n\nPlease report this error in the project issue.")]
24    DeserializationError(String),
25}