use thiserror::Error;
use std::error::Error as StdError;
#[derive(Error, Debug)]
pub enum ChatError {
#[error("Network error: {0}")]
Network(#[source] Box<dyn StdError + Send + Sync>),
#[error("Authentication failed: {0}")]
Authentication(String),
#[error("API error: status={status:?}, message={message}")]
Api {
status: Option<u16>,
message: String, #[source]
source: Option<Box<dyn StdError + Send + Sync>>,
},
#[error("Invalid request: {0}")]
InvalidRequest(String),
#[error("Rate limit exceeded")]
RateLimited,
#[error("Model not found: {0}")]
ModelNotFound(String),
#[error("Content moderated: {0}")]
ContentModerated(String),
#[error("Response parsing error: {0}")]
Parsing(#[source] Box<dyn StdError + Send + Sync>),
#[error("Streaming error: {0}")]
Streaming(#[source] Box<dyn StdError + Send + Sync>),
#[error("Feature not supported: {0}")]
NotSupported(String),
#[error("Configuration error: {0}")]
Configuration(String),
#[error("Tool use error: {0}")]
ToolUseError(String),
#[error("Operation cancelled")]
Cancelled,
#[error("Provider-specific error: {0}")]
Provider(#[source] Box<dyn StdError + Send + Sync>),
}