use thiserror::Error;
use crate::agent::AgentError;
use crate::browser::BrowserError;
#[derive(Error, Debug)]
pub enum UtilsError {
#[error("Missing API key: {0}")]
#[allow(dead_code)] MissingApiKey(String),
#[error("Unsupported provider: {0}")]
#[allow(dead_code)] UnsupportedProvider(String),
#[error("LLM error: {0}")]
LlmError(String),
#[error("Model error: {0}")]
#[allow(dead_code)] ModelError(String),
#[error("IO error: {0}")]
IoError(String),
#[error("Browser error: {0}")]
BrowserError(String),
#[error("Agent error: {0}")]
AgentError(String),
#[error("JSON parse error: {0}")]
JsonParseError(String),
#[error("Unexpected error: {0}")]
UnexpectedError(String),
}
impl From<BrowserError> for UtilsError {
fn from(err: BrowserError) -> Self {
UtilsError::BrowserError(err.to_string())
}
}
impl From<AgentError> for UtilsError {
fn from(err: AgentError) -> Self {
UtilsError::AgentError(err.to_string())
}
}
impl From<serde_json::Error> for UtilsError {
fn from(err: serde_json::Error) -> Self {
UtilsError::JsonParseError(err.to_string())
}
}
impl From<std::io::Error> for UtilsError {
fn from(err: std::io::Error) -> Self {
UtilsError::IoError(err.to_string())
}
}