use thiserror::Error;
pub type Result<T> = std::result::Result<T, OpenApiError>;
#[derive(Debug, Error)]
pub enum OpenApiError {
#[error("failed to fetch OpenAPI spec: {0}")]
FetchError(#[from] reqwest::Error),
#[error("failed to parse OpenAPI spec: {0}")]
ParseError(String),
#[error("failed to read OpenAPI spec file: {0}")]
IoError(#[from] std::io::Error),
#[error("invalid URL: {0}")]
InvalidUrl(#[from] url::ParseError),
#[error("invalid regex pattern: {0}")]
InvalidPattern(#[from] regex::Error),
#[error("API call failed: {0}")]
ApiError(String),
#[error("missing required parameter: {0}")]
MissingParameter(String),
#[error("invalid parameter value for '{0}': {1}")]
InvalidParameter(String, String),
#[error("operation not found: {0}")]
OperationNotFound(String),
#[error("base URL not configured - call with_base_url() before making API calls")]
NoBaseUrl,
#[error("SSRF protection: {0}")]
SsrfBlocked(String),
#[error("request timed out after {0} seconds")]
Timeout(u64),
}
impl From<serde_json::Error> for OpenApiError {
fn from(err: serde_json::Error) -> Self {
Self::ParseError(err.to_string())
}
}
impl From<serde_norway::Error> for OpenApiError {
fn from(err: serde_norway::Error) -> Self {
Self::ParseError(err.to_string())
}
}