anathema_widgets/
error.rs1use std::fmt::Display;
2
3pub type Result<T, E = Error> = std::result::Result<T, E>;
4
5#[derive(Debug)]
6pub enum Error {
7 InvalidElement(String),
8 TreeTransactionFailed,
9 ComponentConsumed,
10}
11
12impl Display for Error {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 match self {
15 Error::InvalidElement(el) => write!(f, "element `{el}` does not exist"),
16 Error::TreeTransactionFailed => write!(
17 f,
18 "failed to insert into the widget tree (most likely the parent was removed)"
19 ),
20 Error::ComponentConsumed => write!(f, "this component has already been used"),
21 }
22 }
23}
24
25impl std::error::Error for Error {}