2016-03-05 03:36:28 +11:00
|
|
|
use std::fmt;
|
|
|
|
|
2020-03-19 04:53:24 +11:00
|
|
|
/// Errors that can be returned from various operations
|
2016-03-05 03:36:28 +11:00
|
|
|
///
|
|
|
|
pub enum Error {
|
2017-08-11 20:41:24 +10:00
|
|
|
/// Returned if menu Menu function isn't supported
|
2016-03-05 03:36:28 +11:00
|
|
|
MenusNotSupported,
|
2017-08-11 20:41:24 +10:00
|
|
|
/// Menu already exists
|
2016-03-05 03:36:28 +11:00
|
|
|
MenuExists(String),
|
2017-08-11 20:41:24 +10:00
|
|
|
/// Menu already exists
|
2016-03-05 03:36:28 +11:00
|
|
|
WindowCreate(String),
|
2017-08-11 20:41:24 +10:00
|
|
|
/// Unable to Update
|
|
|
|
UpdateFailed(String),
|
2016-03-05 03:36:28 +11:00
|
|
|
}
|
|
|
|
|
2020-03-19 04:53:24 +11:00
|
|
|
impl fmt::Debug for Error {
|
|
|
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
2016-03-05 03:36:28 +11:00
|
|
|
match *self {
|
2020-03-19 04:53:24 +11:00
|
|
|
Error::MenusNotSupported => write!(formatter, "Menus not supported"),
|
|
|
|
Error::MenuExists(_) => write!(formatter, "Menu already exists"),
|
|
|
|
Error::WindowCreate(_) => write!(formatter, "Failed to create window"),
|
|
|
|
Error::UpdateFailed(_) => write!(formatter, "Failed to Update"),
|
2016-03-05 03:36:28 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for Error {
|
|
|
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
match *self {
|
2020-03-19 04:53:24 +11:00
|
|
|
Error::MenusNotSupported => write!(fmt, "{:?}", self),
|
|
|
|
Error::MenuExists(ref e) => write!(fmt, "{:?} {:?}", self, e),
|
|
|
|
Error::WindowCreate(ref e) => write!(fmt, "{:?} {:?}", self, e),
|
|
|
|
Error::UpdateFailed(ref e) => write!(fmt, "{:?} {:?}", self, e),
|
2016-03-05 03:36:28 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|