nativeshell/shell/platform/linux/
error.rs

1use std::fmt::Display;
2
3#[derive(Debug, Clone)]
4pub enum PlatformError {
5    NotAvailable,
6    UnknownError,
7    GLibError { message: String },
8    OtherError { error: String },
9}
10
11pub type PlatformResult<T> = Result<T, PlatformError>;
12
13impl Display for PlatformError {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        match self {
16            PlatformError::NotAvailable => {
17                write!(f, "Not Available")
18            }
19            PlatformError::UnknownError => {
20                write!(f, "Unknown Error")
21            }
22            PlatformError::GLibError { message } => {
23                write!(f, "GLibError: {}", message)
24            }
25            PlatformError::OtherError { error } => {
26                write!(f, "{}", error)
27            }
28        }
29    }
30}
31
32impl std::error::Error for PlatformError {}