use thiserror::Error;
#[derive(Error, Debug)]
pub enum ToolError {
#[error("invalid input: {0}")]
InvalidInput(String),
#[error("internal error: {0}")]
Internal(String),
#[error("external service error: {0}")]
External(String),
#[error("permission denied: {0}")]
Permission(String),
#[error("not found: {0}")]
NotFound(String),
}
impl ToolError {
pub fn invalid_input<S: ToString>(s: S) -> Self {
ToolError::InvalidInput(s.to_string())
}
pub fn internal<S: ToString>(s: S) -> Self {
ToolError::Internal(s.to_string())
}
pub fn external<S: ToString>(s: S) -> Self {
ToolError::External(s.to_string())
}
pub fn not_found<S: ToString>(s: S) -> Self {
ToolError::NotFound(s.to_string())
}
pub fn permission<S: ToString>(s: S) -> Self {
ToolError::Permission(s.to_string())
}
}