use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
#[error("Expertise not found: {id} (scope: {scope})")]
NotFound { id: String, scope: String },
#[error("Expertise already exists: {id} (scope: {scope})")]
AlreadyExists { id: String, scope: String },
#[error("Invalid scope: {0}")]
InvalidScope(String),
#[error("Invalid relation type: {0}")]
InvalidRelationType(String),
#[error("Circular dependency detected: {from} -> {to}")]
CircularDependency { from: String, to: String },
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Migration error: {0}")]
Migration(String),
#[error("{0}")]
Other(String),
}
impl From<String> for Error {
fn from(s: String) -> Self {
Error::Other(s)
}
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Error::Other(s.to_string())
}
}