use anyhow::Result as AnyhowResult;
#[derive(Debug, Clone, PartialEq)]
pub enum AnimationError {
ElementNotFound(String),
InvalidTransition { from: String, to: String },
RenderError(String),
EventRegistrationFailed(String),
AsyncFailed(String),
InvalidEventType(String),
}
impl std::fmt::Display for AnimationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AnimationError::ElementNotFound(id) => {
write!(f, "Element not found: {}", id)
}
AnimationError::InvalidTransition { from, to } => {
write!(f, "Invalid transition from {} to {}", from, to)
}
AnimationError::RenderError(msg) => {
write!(f, "Render error: {}", msg)
}
AnimationError::EventRegistrationFailed(msg) => {
write!(f, "Event registration failed: {}", msg)
}
AnimationError::AsyncFailed(msg) => {
write!(f, "Async operation failed: {}", msg)
}
AnimationError::InvalidEventType(msg) => {
write!(f, "Invalid event type: {}", msg)
}
}
}
}
impl std::error::Error for AnimationError {}
pub fn to_anyhow(err: AnimationError) -> anyhow::Error {
anyhow::anyhow!("Animation operation failed: {}", err)
}
pub type AnimationResult<T> = AnyhowResult<T>;