1use std::fmt::Display;
3
4#[derive(Debug)]
6pub enum Error {
7 Unsupported,
9 Unavailable,
11 Platform(Box<dyn std::error::Error + Send + Sync>),
13}
14
15impl Display for Error {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 Error::Unsupported => write!(f, "Unsupported operation"),
19 Error::Unavailable => write!(f, "Unavailable data"),
20 Error::Platform(err) => write!(f, "Platform error: {}", err),
21 }
22 }
23}
24
25impl std::error::Error for Error {}
26
27impl Error {
28 pub fn from_platform(err: impl std::error::Error + Send + Sync + 'static) -> Self {
30 Error::Platform(Box::new(err))
31 }
32}