mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 11:31:32 +11:00
096147f288
std::error::Error::description is deprecated, so I changed the fmt::Display implementation to rely on fmt::Debug implementation, which, in turn, return human-readable messages like description was doing
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use std::fmt;
|
|
|
|
/// Errors that can be returned from various operations
|
|
///
|
|
pub enum Error {
|
|
/// Returned if menu Menu function isn't supported
|
|
MenusNotSupported,
|
|
/// Menu already exists
|
|
MenuExists(String),
|
|
/// Menu already exists
|
|
WindowCreate(String),
|
|
/// Unable to Update
|
|
UpdateFailed(String),
|
|
}
|
|
|
|
impl fmt::Debug for Error {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match *self {
|
|
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"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
match *self {
|
|
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),
|
|
}
|
|
}
|
|
}
|