File size: 1,902 Bytes
94c29e9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
use thiserror::Error;
/// ChatGPT client errors
#[derive(Error, Debug)]
pub enum ChatGptError {
#[error("Network error: {0}")]
Network(#[from] reqwest::Error),
#[error("JSON parsing error: {0}")]
Json(#[from] serde_json::Error),
#[error("Base64 decode error: {0}")]
Base64Decode(#[from] base64::DecodeError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Image processing error: {0}")]
Image(#[from] image::ImageError),
#[error("Invalid proxy format: {0}")]
InvalidProxy(String),
#[error("Challenge solve error: {0}")]
ChallengeSolve(String),
#[error("VM execution error: {0}")]
VmExecution(String),
#[error("IP flagged: Your IP got flagged by ChatGPT")]
IpFlagged,
#[error("Authentication failed: {0}")]
Authentication(String),
#[error("Invalid response format: {0}")]
InvalidResponse(String),
#[error("Configuration error: {0}")]
Configuration(String),
#[error("Unknown error: {0}")]
Unknown(String),
}
/// Result type alias for ChatGPT operations
pub type Result<T> = std::result::Result<T, ChatGptError>;
impl ChatGptError {
pub fn invalid_proxy(msg: impl Into<String>) -> Self {
Self::InvalidProxy(msg.into())
}
pub fn challenge_solve(msg: impl Into<String>) -> Self {
Self::ChallengeSolve(msg.into())
}
pub fn vm_execution(msg: impl Into<String>) -> Self {
Self::VmExecution(msg.into())
}
pub fn authentication(msg: impl Into<String>) -> Self {
Self::Authentication(msg.into())
}
pub fn invalid_response(msg: impl Into<String>) -> Self {
Self::InvalidResponse(msg.into())
}
pub fn configuration(msg: impl Into<String>) -> Self {
Self::Configuration(msg.into())
}
pub fn unknown(msg: impl Into<String>) -> Self {
Self::Unknown(msg.into())
}
}
|