Skip to main content

automata_windows/
error.rs

1/// Error type for UI automation operations.
2#[derive(Debug)]
3pub enum UiError {
4    /// A semantic/logic error (e.g. element not found, unexpected state).
5    Internal(String),
6    /// A platform API error.
7    Platform(String),
8}
9
10impl std::fmt::Display for UiError {
11    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12        match self {
13            Self::Internal(s) | Self::Platform(s) => write!(f, "{s}"),
14        }
15    }
16}
17
18impl std::error::Error for UiError {}
19
20impl From<UiError> for ui_automata::AutomataError {
21    fn from(e: UiError) -> Self {
22        match e {
23            UiError::Internal(s) => ui_automata::AutomataError::Internal(s),
24            UiError::Platform(s) => ui_automata::AutomataError::Platform(s),
25        }
26    }
27}