1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Error types for this crate.
use std::{error::Error, fmt::Display};
/// The error type returned by functions in this crate which might fail.
#[derive(Debug)]
pub enum UIError {
/// Signifies that the underlying library was unable to properly hook into the platform's GUI APIs.
FailedInitError { error: String },
/// Signifies that an attempt was made to initialize a new instance of the underlying library while
/// one already existed.
MultipleInitError(),
/// Signifies that an attempt was made to remove a tab (index) from a tab group that was out of bounds (n).
TabGroupIndexOutOfBounds { index: i32, n: i32 },
}
impl Display for UIError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
UIError::FailedInitError { error } => write!(
f,
"unable to initialize the underlying UI framework: {}",
error
),
UIError::MultipleInitError() => {
write!(f, "cannot initialize multiple instances of libui")
}
UIError::TabGroupIndexOutOfBounds { index, n } => write!(
f,
"tab with index {} is not in tab group of size {}",
index, n
),
}
}
}
impl Error for UIError {}