minifb 0.8.3

Cross-platform window setup with optional bitmap rendering
Documentation
use std::error::Error as StdError;
use std::fmt;

/// Errors that can be return from various operatiors
///
#[derive(Debug)]
pub enum Error {
    /// Returned if menu Menu function isn't supported 
    MenusNotSupported,
    /// Menu already exists 
    MenuExists(String),
    /// Menu already exists 
    WindowCreate(String),
}

impl StdError for Error {
    fn description(&self) -> &str {
        match *self {
            Error::MenusNotSupported => "Menus not supported",
            Error::MenuExists(_) => "Menu already exists",
            Error::WindowCreate(_) => "Failed to create Window",
        }
    }

    fn cause(&self) -> Option<&StdError> {
        match *self {
            Error::MenusNotSupported => None,
            Error::MenuExists(_) => None,
            Error::WindowCreate(_) => None,
        }
    }
}

impl fmt::Display for Error {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Error::MenusNotSupported => {
                write!(fmt, "{}", self.description())
            },
            Error::MenuExists(ref e) => {
                write!(fmt, "{} {:?}", self.description(), e)
            },
            Error::WindowCreate(ref e) => {
                write!(fmt, "{} {:?}", self.description(), e)
            }
        }
    }
}